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

Let Resource Field List .res Files in Directories #9937

Open
mechPenSketch opened this issue Jun 10, 2024 · 1 comment
Open

Let Resource Field List .res Files in Directories #9937

mechPenSketch opened this issue Jun 10, 2024 · 1 comment

Comments

@mechPenSketch
Copy link

mechPenSketch commented Jun 10, 2024

Describe the project you are working on

A battle game where each units are assigned to an element. In each element, there are two lists: one for which elements it is strong to, and the other for which elements it is weak to.

Describe the problem or limitation you are having in your project

Every time I have to choose a resource, I have to dig up the filesystem to find the desired one.

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

Add a new annotation, with a directory path an arguement, for Resource.

For now I'm think of @export_from_dir(String directory = "res://")

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

Using the above project as an example, the elements are stored in the project:

res://
    ∟ elements
        ⊢ air.res
        ⊢ earth.res
        ⊢ fire.res
        ⊢ ice.res
        ⊢ lightning.res
        ∟ water.res

Then, in unit.gd, assign its element as a Resource like the script below:

@export_from_dir("res://elements") var element: Resource

In the scene, Unit is unit.gd extended from Node2D, so in the inspection, it should have Element as a property. Clicking on the field opens the list of elements instead of a list of new resources and further sub-classes (if any), then an option to Quick Load and Load.

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

At best, I can access EditorPlugin.get_editor_interface().get_inspector(). There, however, nowhere in EditorInspector can I edit a property or its field.

Without scripting, Quick Load is the only saving grace of this issue. However, it takes a minimum of four clicks (Drop-down > Quick Load" > Desired Item > Load), and that's using a new extension of Resource.

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

The editor plugin cannot change the way an annotation works. It also hasn't reached the point where it can edit how a node's property is displayed in the inspector.

@aXu-AP
Copy link

aXu-AP commented Jun 11, 2024

If you type your variable as element instead of resource then quick load should show you only relevant results.
ie.

@export var element : Element

or if your element class doesn't have class name:

@export var element : preload("element.gdscript")

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

3 participants