- Home /
Question by
the-figtree · Jul 30, 2011 at 10:44 AM ·
guiguitextureif
Script simply won't budge
Greetings!
This script i'm working on is suposed to be the stage victory trigger. The game is about saving objects tagged as "spirits" by taking them to a specific location. Once they reach the location, score goes ++.
check out the code:
var score = 0;
var DisplayText : GameObject;
var Win : int;
var icon : Texture2D;
function OnTriggerEnter(other : Collider)
{
if (!enabled || other.tag == "Spirit")
{
score ++;
print (score);
Destroy(other.gameObject);
}
}
var victoryTexture: Texture;
function OnGUI ()
{
GUI.Box (Rect (20,22,100,30), GUIContent("Rescued: " + score, icon));
}
if (score == Win)
{
//GUI.DrawTexture(Rect(200,10,60,60), victoryTexture, ScaleMode.ScaleToFit, true,0f);
GUI.Box(Rect(0,0,Screen.width,Screen.height),victoryTexture);
}
Now, almost everything works just fine here. Everything but the if(score == win)! Whenever score goes == win, the victory texture is suposed to be printed on screen, but it simply doesn't happens. no errors, no warnings. it simply won't budge.
Comment
Answer by Justin Warner · Jul 30, 2011 at 10:50 AM
function Update()
{
if (score == Win)
{
//GUI.DrawTexture(Rect(200,10,60,60), victoryTexture, ScaleMode.ScaleToFit, true,0f);
GUI.Box(Rect(0,0,Screen.width,Screen.height),victoryTexture);
}
}
It's not in the update function... =).