This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I've defined an array of custom resources with setget that limits the type.

However, after changing the value of a resource, I noticed that the value is not reflected until I press the save button on the inspector.

extends Resource
export(Array,Resource) var resource_array setget _set_array

func _set_array(new_value : Array):
        var helper =
        resource_array =helper.CreateArray(new_value,audiostream)

func CreateArray(new_value,from_resource) -> Array:
    var result = []
    for element in new_value:
        var elem = element 
        if elem == null:
            elem =
            elem.m_resource = from_resource.duplicate()

    return result

When I refer to the resource in the tool script, the changed data is reflected, but the
When I run the game, the values are not reflected; when I open the tres file, the changed values are not written.

I am afraid of forgetting to save and losing data, so I want to execute the inspector's save button from a script or with a shortcut key.

I tried propertylistchanged_notify() but it did not work.

Godot version version: 3.5.1
in Engine by (12 points)

1 Answer

0 votes

Have the button call a function that does the saving. You can then call that same function by script, no need to try and press the button by script or whatever.

by (16 points)

Thanks for the answer! didn't seem to work if I passed the path to the resource generated by setget (the path that is automatically generated when put into the array). I solved the problem by specifying the path of the resource first and saving it.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.