how to show Texture2D with scripts or GUITexture

i want to create GUITexture with function OnGUI and eneable it with onTriggerHit, here is the script. when i hit collider game stops :frowning: pls help me

var finish : Texture2D;
function OnGui () {
 GUI.Box(Rect(0,0,Screen.height, Screen.width),finish);
}
function OnTriggerEnter(hit : Collider)
{
 if(hit.gameObject.tag == "Finish")
 {
 guiTexture.texture = finish;
 }
}

1 Answer

1

What you can do is the following:

public var finish : Texture2D;
private var showFinish : boolean = false;
function OnGUI() {
	if(showFinish){
		GUI.DrawTexture(Rect(0,0,Screen.height, Screen.width),finish);
	}
}
function OnTriggerEnter(hit : Collider) {
	if(hit.gameObject.tag == "Finish"){
		showFinish = true;
	}
}