I have been attempting to make a GUI Label a variable - but it always errors… Am I doing anything wrong?
using UnityEngine;
using System.Collections;
public class clue : MonoBehaviour {
void Start () {
Screen.SetResolution(1024, 768, true);
}
void Update () {
}
void OnGUI () {
// Main Menu.
var height = Screen.height;
var width = Screen.width;
var label = GUI.Label (new Rect (width/2, height/2, 100, 200), "Menu:");
}
}
I don't think you can use it as a variable, it doesn't return anything and it's not a class itself or variable type. What are you trying to do with it?
– Josh707I will be wanting to get rid of it after about 5 seconds so I thought I would assign it as a variable.
– flatline115Oh, I think you'll have to set it up with a timer/coroutine to turn it on and off, I don't know any other ways of doing it.
– Josh707Thanks, for the information.
– flatline115GUI.Label is a call you make inside of OnGUI(). its not persistant, it just causes the label to be drawn that one time. if the next time OnGUI() is called, you don't call GUI.Label, then your label will disappear.
– kiritaku