- Home /
Question by
Natek_Omega · May 05, 2014 at 04:55 PM ·
javascriptguinullreferenceexception
GUI.Label not set to an instance
NullReferenceException: Object reference not set to an instance of an object UnityEngine.GUI.Label (Rect position, System.String text) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:164) HighScores.OnGUI () (at Assets/Scripts/HighScores.js:79)
I'm getting a null reference exception on the "hello world" line for some reason and I'm pretty certain that OnGUI and GUI.Label are done correctly but they won't print no matter where I put them.
function OnGUI()
{
if(printed == false)
{
for(var i :int = 0; i <10;i++)
{
if(i != newSlot)
{
GUI.Label (Rect (10, 10, 100, 20), "Hello World!");
GUI.Label(Rect (Screen.width/2, Screen.height/2 + (10*i), 200, 20), names[i].ToString());
GUI.Label(Rect (Screen.width/2 + 100, Screen.height/2+(10*i), 200, 20), scores[i].ToString());
}
else if(i==newSlot)
{
newName = GUI.TextField(Rect (Screen.width/2, Screen.height/2 + (i*10), 200, 20), newName);
}
}
printed = true;
}
}
Comment