A quick note on the UI toolkit’s data binding. If you access the bound data immediately after changing a field in the UI, this does not provide the current new value!
The waiting time is about 1 frame.
The following helped me:
public void OnIntegerFieldChanged(ChangeEvent<int> changeEvent)
{
StartCoroutine(UseDataWithWaitForEndOfFrameDelay(changeEvent.newValue));
//UseDataWithoutDelay(changeEvent.newValue);
}
void UseDataWithoutDelay (int newValue) //Demonstrate the Problem
{
Debug.Log("DataValue: " + data.intNumber + " FieldValue: " + newValue);
}
IEnumerator UseDataWithWaitForEndOfFrameDelay(int newValue) //This is working
{
yield return new WaitForEndOfFrame();
Debug.Log("DataValue: " + data.intNumber + " FieldValue: " + newValue);
}
Greetings