Expose EditorFileSystemDirectory.get_file_resource_script_class()
to scripting
#11216
Labels
EditorFileSystemDirectory.get_file_resource_script_class()
to scripting
#11216
Describe the project you are working on
Plugin which interacts with resource files in a project.
Describe the problem or limitation you are having in your project
There is no way to get
class_name
of aResource
withEditorFileSystemDirectory
norEditorFileSystem
(Sidenote; there is a way to get the type, but that is not the
class_name
:https://docs.godotengine.org/en/stable/classes/class_editorfilesystem.html#class-editorfilesystem-method-get-file-type
https://docs.godotengine.org/en/latest/classes/class_editorfilesystemdirectory.html#class-editorfilesystemdirectory-method-get-file-type)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The
FileInfo
struct appears to have the desired information, according to the comment:https://github.com/godotengine/godot/blob/f952bfe9985ad8f507cc29b2c7601bbba18b8039/editor/editor_file_system.h#L59
However, there is no way to get this information in editor scripts.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Exposing the function
get_file_resource_script_class()
fromEditorFileSystemDirectory
to scripting would solve this:https://github.com/godotengine/godot/blob/f952bfe9985ad8f507cc29b2c7601bbba18b8039/editor/editor_file_system.cpp#L189-L192
Also note that
EditorFileSystem
itself has a convience function to get the type of a file, (which internally usesEditorFileSystemDirectory
):https://github.com/godotengine/godot/blob/f952bfe9985ad8f507cc29b2c7601bbba18b8039/editor/editor_file_system.cpp#L1855-L1864
So it might be a good idea to also do that for this one, although that is left up to debate.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Only by loading the resource and checking for type, or reading the first line of a non-binary resource and manually checking for the
script_class
text.Is there a reason why this should be core and not an add-on in the asset library?
Editor functionality.
The text was updated successfully, but these errors were encountered: