Value Changed Event On Create

When I create a PropertyField it raises a value changed event. How can I stop raising this initial event?

the initial change event is;

9833571--1414512--upload_2024-5-14_11-17-1.png

Hi,
This change event is sent when the field is bound, you can not stop it.
You can ignore it by checking if the new and previous values are the same or useTrackPropertyValue which is only sent when the SerialzedProperty changes.

Hi @karl_jones ,

I use RegisterValueChangedCallback for my custom controller. I get value changes from the child elements in BubbleUp phase after I create child fields.

I have both serialized and nonserialized fields. So using TrackProperyValue will not be easy for me.

It is confusing for me to get ValueChanged event without the value changed. I build a framework to override Unity Inspector Editor as Odin does. There should be BindWithoutNotify like SetValueWithoutNotify.

I agree its confusing and have also argued against this internally but unfortunately, it’s been like this for a long time so changing it now would be a big change in behaviour and likely break people’s projects. Ill bring it up with the team again and see what they think.
I don’t think a BindWithoutNotify is the answer though, that would only work under some circumstances. I think it should be changed for a separate binding event instead of using the ChangeValue callback or the ChangeValue event should include additional data that could be used to filter it.

Thanks @karl_jones . I’m glad to hear you agree.

If something illogical in the past, it will be illogical then too :slight_smile: Having to check if the previous and current value is the same in the changeevent is illogical :slight_smile:

I love UI Toolkit. It is very powerful for a software architect. Apart from valuechange issue, RegisterValueChangedCallback is to get all events from the target and the children. GetComponent has versions GetComponentInChildren and GetComponentInParent. RegisterValueChangedCallback’s scope should be a single element. It gets all children’s events. Naming convention is an important part of OOP to make it clear and stop being confusing.

I hope we get better interfaces for these 2 things in future versions of Unity.

This may help to explain the events better https://docs.unity3d.com/Manual/UIE-Events-Dispatching.html
Being able to get events through the hierarchy is very powerful.