- Home /
disable code when level is rendered
I'v probably told you before that i have to disable a script when my level is loaded but the problem is that i don't know what functions or lines of codes i have to use to get this to work. I want to disable a loading script when my "Random_Maze" is finished, my "Loading_Script" is: private var tileCounter = 0; var height:int = 12; var width:int = 12; var updateString: String = "";
function UpdateProgress() {
var progress:float = tileCounter/(height*width*6.0);
updateString = progress.ToString("Loading: #0%");
}
function OnGUI(){
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (0, 0, 3000, 3000),updateString);
GUI.Box (Rect (Screen.width /2 - 100 ,Screen.height /2 - 0,200,50),updateString );
}
can i put like
if (progress.ToString("Loading: 100%")){
script.Loading_Script.isDone
}
or something like that?
Answer by FakeBerenger · Nov 18, 2012 at 01:18 PM
You could do a string comparison like
if( updateString == "Loading: 100%" ) ...
But it seems clumsy. You should test on the actual variable progress like so
if( progress == 100 ) ...
As for disabling a script, you can use enabled = false;
or just do:
OnBeginLoading() { m_isLoaded = false; }
OnEndLoadind() { m_isLoaded = true; }
Don't forget to mark the answer as 'correct' by clicking the check mark icon.