-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Add automatic imports for node and class references #3695
Comments
Sounds like perfect use-case for #1047 |
I know that class_name would fix half of this issue, but I like being explicit about dependencies and dislike polluting the global namespace. Manually importing also gives you the ability to change the class name. |
I can see this would be immensely useful, but I can also imagine the way it would work may be a bit too ambiguous. |
I have thought about this proposal after godotengine/godot#60298 was merged, and I agree that using this feature and |
I see potential in the idea, whatever the solution may be. Cluttering the global namespace undeniably scales horribly on larger projects, so some way to make that less of a burden is very welcome. |
Describe the project you are working on
A large projects with many node and class references:
Describe the problem or limitation you are having in your project
Storing node references and including scripts as types is something very common, but is not automated inside Godot without using external tools.
I wrote an addon to automate the task, which I use every day: https://github.com/Jummit/node-referencer-addon
It isn't as quick as I would like it though. (I have to open the script I want to include, go to
Tools>Reference>Copy Class Reference
and then paste the reference in the script I need it in)Describe the feature / enhancement and how it helps to overcome the problem or limitation
Something available in many other languages is a feature called "Auto-Importing". When referencing a class that hasn't been imported yet, autocompleting it will add the import to the top of the script. This is also something that can be exposed to the language server.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
When writing the name of a script in PascalCase, an autocompletion hint is added that when triggered, adds a line like this to the top of the script:
Mockup:
When writing the name of a node in the scene tree, the node name shows up in the autocompletion, and when triggered, adds the node reference to the top:
Mockup:
When the project setting "Add Type Hints" is enabled, these could be typed as well.
If this enhancement will not be used often, can it be worked around with a few lines of script?
It will be used often.
Is there a reason why this should be core and not an add-on in the asset library?
As I mentioned, I wrote an addon which isn't as well integrated into Godot. It also doesn't give the language server access to the functionality.
The text was updated successfully, but these errors were encountered: