Open willnationsdev opened 5 years ago
Im supporting this, this would be great!
This issue is blocking me from implementing saves, because currently, I can't get all scripts and call a function.
@sairam4123 Just so that you are aware, PRs godotengine/godot#44879 (for 3.x) and godotengine/godot#48201 (for 4.0) include this change.
Also, implementation of these methods should not be a "blocker" of any sort. This data is already accessible from the ProjectSettings
singleton via hidden properties in the project.godot
file.
You can see the serialization process, and which variables are being written to for which purposes, here. You can then see the way the data is deserialized back into the ScriptServer here. You can replicate this code in GDScript easily enough. For example, Godot Next has a ClassType
script which has utility methods to fetch this information. This method for example fetches all of the global script classes and binds their name to a Dictionary containing all of their information (such as "language" name, file "path", "class" name, and "base" class name), so you can, iirc, load the script using load(script_map["MyClass"]["path"])
, etc.
If you need to iterate through all scripts in the res://
directory rather than just the global script classes, then you can do that yourself using the File class, as Godot Next also demonstrates in its FileSearch class.
Describe the project you are working on: I am attempting to implement #18, #22, and #43 which involve changes to both
/editor
and various/modules/*
directories.Describe how this feature / enhancement will help your project: None of those codebases should be dependent on each other. All should only be aware of the engine core (
/core
,/scene
, etc.). I am finding myself duplicating certain script-class-related algorithms across EditorData / other editor classes and the various ScriptLanguage implementations in modules. It would simplify things greatly if all of these utility algorithms could be sourced from the actual core class that is responsible for managing script classes, so the code can be shared between several contexts (which, ya know, would actually make sense).Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Thus far I have code in the following places that has been duplicated:
I haven't even approached C# script classes, nor tried to create a global access point for script class references in NativeScript, both of which could benefit from the utility algorithms I'm using.
Describe implementation detail for your proposal (in code), if possible:
Add the following three utility methods to ScriptServer:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
It is engine related, not script related.
Is there a reason why this should be core and not an add-on in the asset library?:
It is engine related, not script related.