Odin Inspector can't update NaN double

Issue #661 resolved
Mike Wyatt created an issue

Odin Inspector doesn’t update double fields when the previous value is NaN.

To reproduce:

  1. Add the script below to a GameObject.
  2. Change the value of a to any number (e.g. 2)
  3. Notice how the value of b doesn’t change, and it remains NaN.
public class OdinBugTester : MonoBehaviour {
    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)

  1. Tor Esa Vestergaard

    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 🙂

  2. Log in to comment