Can I not use custom gdscript classes in C#?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Abstraction Mage

If I declare a custom class in GDScript by typing class_name CustomGDScriptClass, I can’t use MyGDScriptClass as a type in C#:

public class CsharpClass : Node {
    public CustomGDScriptClass someVariable;  
}

// does not compile as CustomGDScriptClass is not a known type

Is it actually impossible to reference GDScript classes in C# or am I missing some sort of workaround?

:bust_in_silhouette: Reply From: juppi

Take a look at this Doc:
https://docs.godotengine.org/en/stable/tutorials/scripting/cross_language_scripting.html

You have to Load and cast the GDScript like for example:

GDScript someVariable = (GDScript) GD.Load("res://CustomGDScriptClass.gd");