Hi there.
To test a few things, I want my GUI to show results at the end of my game. While I suceeded in getting the GUI Box/Button to show up, the text doesn’t show for some reason and I don’t know why. Even removing the condition for the GUI doesn’t make the string show up. Here is the code, though I’m going to cut most of it so my problem isn’t cluttered here.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System;
using System.Linq;
public class RoomSpawn : MonoBehaviour
{
public int choiceNum = 0;
GameObject engine;
public bool results = false;
public string outcome;
// Use this for initialization
void Start ()
{
Debug.Log("START --> " + this);
StartCoroutine (EndGame());
}
IEnumerator EndGame() {
while (true) {
yield return null;
if (door.open && !door.spawnOnce) {
GameObject engine2 = GameObject.Find("Engine_Freud_Signs");
int freud_level = engine2.GetComponent<FreudUtil>().currentQuizLevel;
int max_level = engine2.GetComponent<FreudUtil>().maxLevel;
if ( freud_level < max_level ) {
//Code here involves irrelevant rendering and instantiation parameters I've taken out for this question
float o,c,e,a,n;
o = (float)engine.GetComponent<FreudUtil>().metricValue('O');
c = (float)engine.GetComponent<FreudUtil>().metricValue('C');
e = (float)engine.GetComponent<FreudUtil>().metricValue('E');
a = (float)engine.GetComponent<FreudUtil>().metricValue('A');
n = (float)engine.GetComponent<FreudUtil>().metricValue('N');
outcome = "Openness: " + o + //
-
"Conscientiousness: " + c + //
-
"Extraversion: " + e + //
-
"Agreeableness: " + a + //
-
"Emotional Stability: " + n; } } else { engine2.GetComponent<FreudUtil>().EndQuiz(); results = true; yield return new WaitForSeconds(10.0f); Application.LoadLevel("TempEnd"); } }
}
void OnGUI () {
//if (results == true) {
GUI.Button ((new Rect (0,50,150,150)), outcome);
//}
}
}