Godot Version
4.2.2
Question
What I wanna do is like below, which is not work.
[C#]
public async Task<int> Test()
{
return await SomeAsyncFunc();
}
[Gdscript]
func do_test():
var result = await C#Obj.Test()
The error is “Invalid call. Nonexistent function Test”
If it is not possible to do this, that means I can only use signal to do the async thing between c# and gdscript.
[C#]
public async Task<int> Test()
{
int res = await SomeAsyncFunc();
EmitSignal(SignalName.SignalTest, res);
}
[Gdscript]
func do_test():
C#Obj.Test()
var result = await C#Obj.SignalTest
I’ve tested, this works.
But the problem is, if there are multiple calls of do_test(), then every “await C#Obj.SignalTest” will be triggered once the first signal is emitted. I have to do more work on this to fix it.
So is there a way to await C# async method in gdscript?