I have a script attached to an object. Before this last modify script work correctly, but I did manually assign the texture. The last added is the part of code that can read texture from object material. (This is only a part of script, with last change):
var btnTexture : Texture;
function Start () {
btnTexture = renderer.material.GetTexture ("_MainTex");
}
function OnGUI () {
windowRect = GUI.Window (0, windowRect, DoMyWindowT, "");
}
function DoMyWindowT (windowID : int){
GUI.DrawTexture(Rect(0,0,windowRect.width,windowRect.height), btnTexture, ScaleMode.ScaleToFit, true, 0f);
}
The script can read main texture object and use in GUI.DrawTexture, but when I start the scene unity say me that texture is not assigned and crash.
UnassignedReferenceException: The variable btnTexture of ‘GUI Object’ has not been assigned.
You probably need to assign the btnTexture variable of the GUI Object script in the inspector.
Somebody help me?