- Home /
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 :( 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;
}
}
Comment
Best Answer
Answer by LesPaul · Apr 18, 2013 at 06:10 PM
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;
}
}
Your answer
Follow this Question
Related Questions
How to save screenshot then use it as a gui texture? 2 Answers
Can't display PNG texture within GUI calls 1 Answer
Gui Toggle help 2 Answers
How to set a texture resource to texture type "GUI" by script? 1 Answer
GUI Texture Spinner - Dead Center 1 Answer