stride icon indicating copy to clipboard operation
stride copied to clipboard

Public variables are not updated on editor when changed on script

Open Asatte32 opened this issue 2 months ago • 3 comments

Release Type: Official Release/GitHub (please choose appropriate option)

Version: 4.3.0.2507

Platform(s): Windows

Describe the bug When a public variable is declared on script, it is only updated on editor when attached to an entity for the first time. The variables are not updated on editor when changed via script. This can became a headache if many entities share the same script but a value needs to be changed.

To Reproduce Steps to reproduce the behavior:

  1. Create a script and declare a public variable on it
  2. Attach the script to an Entity
  3. Update the value of the variable on script
  4. Confirm value is not updated on editor or on run

Expected behavior When a public variable changed on Script, the editor values should also be updated unless they are modified before (An option to clear override on editor can be added)

Asatte32 avatar Nov 20 '25 19:11 Asatte32

I believe this is the intended behavior. Once a component with an entity is serialized together with a scene or a prefab, the values set in the editor remain unchanged. How else would it be possible to assign different values for individual instances of entities in the scene? For example, if I want to have an object in the scene multiple times, each with different values for its public parameters.

If I want a certain value to be the same for all entities of that type, there’s no reason to expose it as a public property — it would make more sense to define it as a constant instead (maybe??)

dawnmichal avatar Dec 08 '25 10:12 dawnmichal

I understand your point and it may indeed be the intended behavior on Stride development. But, unless I updated the value on the editor, since it is not edited, I would expect it to have the value on the script till I change it. Godot seems to be handling this well by updating the values that are not modified and keeping the ones that are changed on editor.

This could be a feature request and not a bug now that I think about it

Asatte32 avatar Dec 08 '25 10:12 Asatte32

Currently you have to set the DefaultValue attribute to get it to change, then it won't serialize the values and should update if you change it in the code. I'd agree it's a bit cumbersome though and would make sense to have it work by the default value assgined to the properties.

[DataMember, DefaultValue(9.81f)] public float G { get; set; } = 9.81f;

johang88 avatar Dec 10 '25 18:12 johang88