I’m probably doing something wrong here, but why does changing the label of a text field trigger a value changed event?
protected virtual void AttachToPanelHandler(AttachToPanelEvent evt)
{
if (DebugEnabled)
Debug.Log($"{ToString()}.AttachedToPanel");
_textField = new TextField();
_textField.RegisterValueChangedCallback(evt =>
{
Debug.Log($"Did someone say {evt.newValue}?");
});
Add(_textField);
Debug.Log($"Added field.");
_textField.label = "1";
_textField.value = "A";
_textField.label = "2";
_textField.value = "B";
}
The output of that code in my project is this:
I’m a bit lost, why setting the label text to “1” doesn’t trigger the event handler, while setting it to “2” a few lines later does. Is updating a label text supposed to trigger the value changed event of the text field? If so, any ideas where that first event might have disappeared?
And what would I have to do, if my code actually should be able to react to changes of the label and the actual text field value, but in different ways? How can I find out who the actual source or sender of a certain event is?
I’m using Unity 2022.2.16 btw.