Search Issue Tracker
Fixed in 2020.2.9f1
Votes
0
Found in
2018.3.0a7
2018.4
2019.4.1f1
2020.2
Issue ID
1257445
Regression
Yes
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
-
petersvp
Jan 18, 2023 08:52
Solution for this problem:
https://gist.github.com/petersvp/251f9128b5102a8b8a102337725ae220 -
petersvp
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....]
-
petersvp
Jul 14, 2020 07:20
Seriously, NANs exist with A REASON!
-
petersvp
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.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- CSS is not applied when using USS type selector "GridBackground"
- Player .exe remains open as a background task after closing it when Active Input Handling is set to "Input System Package (New)"
- Exception block is being rewritten to throw an incorrect number of exceptions when running a project built using IL2CPP Scripting Backend
- [Android] [Vulkan] Warning "AndroidPlayer "<device>" VULKAN: GENERAL WARNING: The following warning was triggered: VKDBGUTILWARN003." spammed every frame when the application is actively running on a device
- Skinning Editor missing tooltips
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.