how to eneable GUI.Box

i’ve created GUI.Box with function OnGUI and assigned it to Texture2D now i want to eneable it with function OnTriggerHit and when i write finish.eneabled = true; it doesnt work, so pls help me there is the script.

var finish : Texture2D;
function OnGUI (){
GUI.Box(Rect(0,0,Screen.width, Screen.height),finish);
}

function OnTriggerHit (hit : Collider) {
if(hit.gameObject.tag == "Finish")
 {
 finish.eneabled = true;
 }
}

Enabled is spelled incorrectly. Also, you have not created the finish variable as a GUITexture.

    var finish : GUITexture;
    function OnGUI (){
    GUI.Box(Rect(0,0,Screen.width, Screen.height),finish);
    }
     
    function OnTriggerHit (hit : Collider) {
    if(hit.gameObject.tag == "Finish")
    {
    finish.enabled = false;
    }
    }

Try this.

Also, GUI’s are not really my thing. :slight_smile:

I don’t know that it’s possible to actually enable/disable a texture. If you’re wanting the box to only draw at certain times though you could add a boolean and make that true or false instead, then use that to determine if you draw the box

var finish : Texture2D;
var finish_enabled : bool;
function OnGUI(){
  if (finish_enabled){
    GUI.Box(Rect(0,0,Screen.width, Screen.height),finish);
  }
}

function OnTriggerHit(hit : Collider){
  if (hit.gameObject.tag == "Finish"){
    finish_enabled = true;
  }
}

Sorry if my syntax is off a bit, I’m more used to C#, but that’s the basic idea