Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register non-GDScript classes as global classes #4405

Open
atirut-w opened this issue Apr 15, 2022 · 2 comments
Open

Register non-GDScript classes as global classes #4405

atirut-w opened this issue Apr 15, 2022 · 2 comments

Comments

@atirut-w
Copy link

Describe the project you are working on

N/A

Describe the problem or limitation you are having in your project

Long story short I had to use Kaitai Struct in my project and have chosen C#, which means GDScript and C# interopt. I found out that I cannot refer to my wrapper class(for tying KS into the Godot-land) by its class name. This forced me to use load()/preload(). I then discover that, from GDScript, Godot does not know about any methods I have defined in my C# script. This means no autocompletion from the GDScript side at all. This makes GDScript/non-GDScript language interopt a huge pain.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Allowing GDScript codes to refer to non-GDScript classes by name obviously makes using multiple languages a lot smoother. for example, you can define a C# class:

public class MyNode : Node

And refer to them by name in GDScript without having to use load() or preload(), with full autocompletions

var node := MyNode.new()

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I don't know how Godot's internals work, but since there are ways to register classes in C++(ClassDB), that could probably be used to register non-GDScript classes just like with C++.

If this enhancement will not be used often, can it be worked around with a few lines of script?

As far as I know, there are no way to register non-GDScript classes from any language other than C++. Even with C++, I don't even know if it's possible to scan C# classes.

Is there a reason why this should be core and not an add-on in the asset library?

See above

@Calinou Calinou changed the title Register non-GDScript classes as global classes. Register non-GDScript classes as global classes Apr 15, 2022
@Calinou
Copy link
Member

Calinou commented Apr 15, 2022

Doesn't godotengine/godot#48201 address this (according to godotengine/godot#40147 (comment))? If so, I think this is a duplicate of #18.

@atirut-w
Copy link
Author

according to godotengine/godot#40147 (comment)

Not sure about that, but I'll subscribe just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants