0 votes

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?

Godot version v3.4.4.stable.mono.official [419e713a2]
in Engine by (12 points)

1 Answer

0 votes

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");
by (1,071 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.