- Home /
how can I use function pointer/delegate in #pragma strict javascript ???
I'm using javascript write our Game in unity3d. I use variable store the function and call it somewhere such as:
var foobar; function test() { ... do something; }
function Start () { foobar = test; }
Then I can call foobar as a funciton directly.
But when I add #pragma strict at the top of this script. It comes error that foobar need to be strong type. So I don't how can I fullfil the job above in #pragma strict.
Thanks in advance.
Answer by Bunny83 · Mar 02, 2011 at 10:33 AM
Well, i didn't use JS but it should work with the type Function
:
var foobar : Function; function test() { ... do something; }
function Start () { foobar = test; }
In C# you would create a delegate:
delegate void FooBarFunction();
FooBarFunction foobar; [...]
HI, many thanks! It is the answer. I first try to use var foobar:function but failed. And your post just re$$anonymous$$d me it should be Function.