-
assigned issue to
Odin Inspector can't update NaN double
Issue #661
resolved
Odin Inspector doesn’t update double fields when the previous value is NaN.
To reproduce:
- Add the script below to a GameObject.
- Change the value of
a
to any number (e.g. 2) - Notice how the value of
b
doesn’t change, and it remains NaN.
public class OdinBugTester : MonoBehaviour {
[OnValueChanged(nameof(Refresh))]
public double a;
public double b = double.NaN;
private void Refresh() {
Debug.Log($"Updating b to {a}...");
b = a;
}
}
I’m using Unity 2019.2.14f1 on a Windows 10 machine.
Comments (4)
-
-
- changed status to open
-
This was apparently related to the fact that float.NaN and double.NaN are not equal to anything, not even themselves. This would make Odin think that any NaN value was being changed every frame, since “oldValue == currentValue” would be false, despite old and current both being NaN, and so Odin would set any NaN value to NaN every frame. I’ve now implemented some custom equality comparer logic for floats and doubles, that consider NaN to be equal to NaN. The fix should be in 2.1.13. Cheers for reporting this
-
- changed status to resolved
- Log in to comment