c# - Unity WaitForSeconds stuck -
i tried create simple splashscreen. @ first waitforseconds working, after few week code doesn't want work. tried using debug.log "before wait" , "after wait" doesn't appear after 5 minutes. using unity 4.5, why happen?
void start () { guitexture.pixelinset = new rect (0, 0, screen.width, screen.height); startcoroutine (loadnextscene ()); } ienumerator loadnextscene(){ debug.log ("before wait"); yield return new waitforseconds (delaytime); debug.log ("after wait"); if (nextlevel != "") { application .loadlevel (nextlevel ); } }
your code perfect. means 1 of 2 things:
- delaytime excessively large (debug out) or, more likely:
- the gameobject destroyed coroutine nolonger running.
try this:
void start () { guitexture.pixelinset = new rect (0, 0, screen.width, screen.height); startcoroutine (loadnextscene ()); } ienumerator loadnextscene(){ debug.log ("before wait. pausing seconds: " + delaytime); yield return new waitforseconds (delaytime); debug.log ("after wait"); if (nextlevel != "") { application .loadlevel (nextlevel ); } } void ondestroy() { debug.log("destroyed"); }
Comments
Post a Comment