Godot Version
Godot 4.2.1
Question
Hello Guys, i’m new of godot and i’m trying to implement some cross-language code. Here is my problem, i’m working in C# but i have one addon in gdscript, i just need to have this gdscript as a Singleton. Now if i instantiate it in the autoload:
and try to call the node:
public partial class GameManager : Node
{
//AddManager
AddManager AddM;
public override void _Ready()
{
//AddManager
AddM= GetNode<AddManager>("/root/AddManager");
}
}
it returns this error: "CS0246: The type or namespace name ‘AddManager’ was not found. You’re probably missing a using directive or assembly reference. "
If i try to instantiate it from my C# script and set it as a Singleton (from script) is just disposed the moment i switch scene:
public partial class GameManager : Node
{
//AddManager
GodotObject AddM;
public override void _Ready()
{
//AddManager
GDScript MyGDScript = GD.Load<GDScript>("res://add_manager.tscn");
AddM = (GodotObject)MyGDScript.New();
//Added to singletons
GetTree().Root.AddChild((Node)AddM);
AddM.Call("_ready");
}
}
What shoud i do?
It is possible to call that singleton from my C# code?
It is possible to make my node a Singleton in code?
I hope I explained myself as best as I could. Thanks in advance to anyone who tries to give me a hand