#Anyone know why the same member for a resource appears twice in the inspector?

11 messages · Page 1 of 1 (latest)

edgy plank
#

When viewing a property which is a custom resource by clicking on its instance as a property of another object in the debugger, there appear to be two instances of each member in the inspector, and they are not the same. In the case in the video, I had changed the Inventory instance's batteries property from 0 to 1 earlier in the code. This change is represented by one of the instances and not the other. This is the entirety of the Inventory script:

class_name Inventory
extends Resource

signal items_changed(inventory: Inventory)

@export var batteries := 0:
    set(new_value):
        batteries = new_value
        
        items_changed.emit(self)

If you need to see more, I'll be happy to share my project or a minimal reproduction project.

#

its weird cause i've worked with resources like this before and not had any issue like this

sullen steppe
# edgy plank its weird cause i've worked with resources like this before and not had any issu...

I dont use godot script editor thus its debugger but i have a theory, mby the Batteries under Inventory is the default value you set when selecting your node (Which dosent live update i believe).

But the one under the member is a live update version for ease of debuging, im guessing this can be confirmed by creating a private variable in the script and see if it pops up in that member category.

edgy plank
#

Adding a private property makes it appear under Members but not under Inventory. This makes me think that the props under Inventory represent the exported values.

sullen steppe
#

Ye i believe that is the case

edgy plank
#

in this case i set the exported batteries property to 4 with the godot editor. So I guess the batteries under Inventory doesn't represent the exported variable

sullen steppe
#

showing double because one is live updating with debugging and the one under inventory is there because you used export on it and its not updating because export values dont live update when modified via code at runtime.

edgy plank
#

in this case i changed the default value in the script to 5.

sullen steppe
#

Yep

edgy plank
#

weird, i wonder why it does that

sullen steppe
#

ye i understand it but it can prob be confusing, basically if its under Members then its a live updating for debugging convenience.