Search Issue Tracker
Fixed in 2020.2.9f1
The value of a float or double field becomes "0" when inputting "0/0" in the Inspector
How to reproduce:
1. Open the project "case_1257445-NaN"
2. Open the Scene "SampleScene"
3. Select the "GameObject" in the Hierarchy
4. Change the value of the field "varFloat" to "0/0" in the "New Behaviour Script (Script)" component in the Inspector
Expected results: the value of the field "varFloat" changes to "NaN"
Actual results: the value of the field "varFloat" changes to "0"
Reproducible with: 2018.3.0a7, 2018.3.14f1, 2018.4.25f1, 2019.3.16f1, 2019.4.3f1, 2020.1.0b15, 2020.2.0a17
Not reproducible with: 2018.3.0a6
Jan 18, 2023 08:52
Solution for this problem:
Jul 14, 2020 07:22
No seriously NANs exist with a reason! It's our issue if floating point NAN propagation kills everything. NANs is also a test tool, and can also be used as memory-efficient way to tell a float that it has no value, instead of using bool hasValue - we already have float.isNan? What is next, Unity? to disable Infinities?
[if anyone ever reads these....]
Jul 14, 2020 07:20
Seriously, NANs exist with A REASON!
Jul 14, 2020 07:19
This is not an acceptable behaviour! Most of my game custom logic DEPENDS of NAN input and i carefully check for float.isNaN! Now I am forced to either create the default value be NAN or editing the Unity Scene File directly. I cannot just go and refactor my code because I must refactor A LOT of scenes and objects. So far I am going with custom property drawer that supports NANs but this isn't good idea. Typing in "0/0" is advanced use and I gues you should give us a way to fill in NANs intentionally.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Can't import asset via Package Manager when it consists of sub-packages and one of them is already imported
- CubemapArrays and Cubemaps take up significantly more memory than on other platforms when working with a Windows project
- The Weight Field in the LimbSolver2D Component for 2D IK Can’t Be Animated or Smoothly Transitioned
- Selected “Landscape Left” orientation of the “ScreenOrientation” dropdown in the Inspector window gets deselected when deselecting and selecting GameObject that contains a “ScreenOrientation” dropdown
- Shader Graph and the Visual Effects Graph scroll unreasonably fast on OSX
Resolution Note (fix version 2020.2.9f1):
This is an intended behaviour as the NaN value type is not really used for anything. Before this we only changed the value from NaN to 0 for double types. In that version it was also fixed to include float types. As NaN requires special handling to avoid issues and that it doesn't really serve a good purpose, these changes were made.