Search Unity

Why sometimes i cannot force certain value in editor to be zero ?

Discussion in 'Getting Started' started by narf03, Sep 15, 2016.

  1. narf03

    narf03

    Joined:
    Aug 11, 2014
    Posts:
    223
    Like Pos Y, it keeps at "-3.051758e-05" instead of "0", i know that value is very very close to zero, but i everytime i sees something not default i always attempt to fix it, it just wont allows me. Are there anyway to allow me to force unity editor to be like 2-3 decimals ?
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    It's a bug of some sort, I'm sure. For all intents and purposes, that value is zero. But if you, like me, have something inside you that requires the field to actually read zero, what you can do to work around it is first change the field to a non-zero value (i.e., "5"), then change it to zero.

    It's a bit annoying to have to do this when you're copying a bunch of UI elements and have to change/reset half the values, but it works.
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Right, I assume what's going on is when you enter a value, Unity compares it to the previous value to see if it's changed. If it hasn't changed, it doesn't reapply your entry, because in some cases that could have unwanted side-effects.

    But in a case like this, it's comparing floating point values, and checking for equality on those is a very dicey proposition. So it checks for "close enough" equality. And a number like that is close enough to 0 that it doesn't reckon you've really entered a new value.
     
  4. narf03

    narf03

    Joined:
    Aug 11, 2014
    Posts:
    223
    oh it worked, didnt know changing the value to other value 1st then back to 0 will make it work, really helps alot, thanks.
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
    Or as Brackeys put it "It's as close to zero as you can get". I remember seeing them mention it in one of their tutorials back when the Unity UI was still very new. It's definitely a bug.