- Home /
Question by
TimKraemer · Nov 22, 2015 at 09:40 AM ·
eventjavascript-specificevent-listener
uJS: listening to C# delegate events with function parameters
Hey there,
I'm trying to follow the tutorial on events. I created an EventManager in C# like that in the tutorial:
public class EventManager : MonoBehaviour {
public delegate void tutorial_check_step(int step);
public static event tutorial_check_step on_tutorial_check;
void OnGUI() {
if(GUI.Button(new Rect(Screen.width / 2 - 50, 5, 100, 30), "Click")) {
if(on_tutorial_check != null)
on_tutorial_check(0);
}
}
}
Now I'm trying to listen to the events with uJS - and it works fine with a function without any parameters. However with parameters I fail to find the correct syntax:
function OnEnable() {
EventManager.on_tutorial_check += check_test;
}
public function check_test(step:int):void {
Debug.Log("finished step"+step);
}
compiler throws:
The event 'EventManager.on_tutorial_check_step' expects a function reference compatible with 'function(): void'.
Comment