- Home /
Question by
finalunpure · Feb 09, 2014 at 07:48 AM ·
scriptable object
NullReferenceException: Object reference not set to an instance of an object
Hi guys im new to Unity and i've got this error which i wanted to basically Press "E" to display the GUI.DrawTexture. However i got this error which i dont understand where the problem is. Here's my code.
var guiShow : boolean = false;
var Note : Texture2D;
function OnTriggerStay ()
{
if (Input.GetKey(KeyCode.E))
{
guiShow = true;
OnGUI();
}
}
function OnTriggerExit ()
{
guiShow = false;
}
function OnGUI()
{
if (guiShow == true)
{
GUI.DrawTexture(Rect(Screen.width/20, Screen.height/20,1024,512) , Note); //<-something wrong
}
}
Comment
Do you have a texture assigned to Note (i.e. probably drag/drop in Inspector)?
Your answer
![](https://koobas.hobune.stream/wayback/20220613132952im_/https://answers.unity.com/themes/thub/images/avi.jpg)