Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mbennett |
I can’t find any examples of doing something like: callback_function = funcref(self, “someFunction”)
in C#. Does anyone know how to do this.
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mbennett |
I can’t find any examples of doing something like: callback_function = funcref(self, “someFunction”)
in C#. Does anyone know how to do this.
Reply From: | Zylann |
funcref
is mostly a shortcut available in GDScript that makes it easier to wrap functions.
In C# you can use lambda functions provided by the language already:
var f = (int x) => { obj.TheFunction(x); }
f(42);
If you still want to use FuncRefs in C#, you can do this:
var f = GD.FuncRef(obj, "TheFunction");
f.CallFunc(42);