Unityscript …
I am in routine BB and I want routine CC to run, in the next frame. The elegant solution would look something like…
Invoke( "CC", one frame );
Is there such a thing? If you try Invoke( “CC”, 0.00001 ) does that in fact safely mean next frame – investigation says NO, that does not work. Perhaps some undocumented parameter?
PS I am fully aware you can do this by calling DD where DD is
function DD() { yield; CC(); }
but then that’s a coroutine, blah blah. (Come to think of it, I guess you could make a InvokeNextFrame(F:Function){yield;F();} But it’s not elegant or builtin.)
Anyway does anyone know the elegant way to “Invoke next frame” ? Thanks a million.
Exactly as my copain below says, in unityscriot, you can test like this:
private var index:int = 0;
function Update()
{
if ( ++index > 10) return;
Debug.Log("runloop "+index);
Invoke("Print",0.00001);
}
function Print()
{ Debug.Log("printer "+index); }
You will see it does not work, not reliably anyway.
By the way, here’s a demo that the inelegant “call a caller” function works as far as it goes.
private var index:int = 0;
function Update()
{
if ( ++index>10) return;
Debug.Log("in loop "+index);
INFPrint();
}
function Print()
{Debug.Log("printer "+index);}
function INFPrint() { yield; Print(); }
// INF means Invoke Next Frame
same deal for this InvokeNextFrame(F:Function){yield;F();
Maybe it’s really better just to have your own runloop going :-/