Reproduction steps:
- Open the attached (UnsignedVariablesTest.zip) project
- Open the “Assets/Scenes/SampleScene.unity” Scene
- Enter the Play Mode
- Select the “Directional Light” GameObject in the Hierarchy window
- Check the “Set Max Uint Value” and “Set Max Ulong Value” boxes under the “New Behaviour Script” Script Component
- Observe the “Uint Value” and “Ulong Value” values in the Inspector window and in the Console
- Try setting the same value in the Inspector window to match the value presented in the Console
- Observe the values in the Console and in the Inspector window
Expected result: Values match between the Console and in the Inspector window
Actual result: The values don’t match between the Console and the Inspector window
Reproducible with: 2020.3.44f1, 2021.3.16f1, 2022.1.24f1, 2022.2.2f1, 2023.1.0a25
Reproducible on: Windows 10 (21H2)
Notes:
- When setting the max value with the “Set Max Uint Value” and “Set Max Ulong Value” fields from the Inspector window, both values report -1 in the Inspector window, however, they are actually set to their max values from the Script and it’s seen in the Console
- When setting the max value of uint in the Inspector window manually it reports the max value of a signed int variable and it doesn’t allow entering a value above it, however, entering a negative value is possible, which shouldn’t be, and the actual value is set to 0
- Similar behaviour as described in the previous notes is also seen with ulong variable. Setting a negative value for ulong from the Inspector window results in a value, which is calculated by subtracting the entered negative value from the max value of unsigned long
- TL;DR Inspector doesn’t represent the actual value once it goes beyond the value of a regular int or long (either in the positive or negative side)