c# - Using 'IEnumerator' to reposition object as soon as it moves outside of camera's field of view) -


this code should reposition gameobject leaves camera's field of view. however, gameobject never gets repositioned...

ienumerator reposition(ninjastar ninjastar) {     bool onscreen = true;     renderer renderer = ninjastar.gameobject.getcomponent<renderer> ();      yield return new waitforseconds (1);      while (onscreen) {         if (!renderer.isvisible) {             ninjastar.initiate (0, 0, vector3.zero); //this code never gets called             ninjastar.transform.position = poolposition; //this code never gets called             onscreen = false; //this code never gets called         }         yield return null;     } } 

renderer.isvisible documentation states:

when running in editor, scene view cameras cause value true.

so try build project preferred platform , test there (for example build windows , test .exe).

alternatively, reposition/rotate scene view cameras dont see object , test in editor.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -