Search Issue Tracker
Fixed in 2021.2.X
Fixed in 2020.3.X
Votes
0
Found in
2019.4
2020.1
2020.2
2020.2.1f1
2021.1
2021.2
Issue ID
1304581
Regression
No
[UIElements] ArgumentException is thrown when the PropertyField is bind to the BuildTarget enum
How to reproduce:
1. Open the user's attached "TestUIElements.zip" project
2. Select the "TestObject" ScriptableObject in the Project window
3. Observe the Inspector window
Expected result: BuildTarget enum is displayed in the Inspector window
Actual result: BuildTarget enum is not displayed in the Inspector window and "ArgumentException: Default Index is beyond the scope of possible value" error is thrown in the Console log
Reproducible with: 2019.4.18f1, 2020.1.17f1, 2020.2.2f1, 2021.1.0b2, 2021.2.0a1
Could not test with: 2018.4.30f1 (UIElements are not supported)
Notes:
- The issue is not reproducible with custom enums
- The issue is not reproducible with other built-in Unity enums
--
The problem is not coming from the fact there are multiple enum entries with the same value, it's from the fact that there is no enum value that equals zero. Since the enum member is initialized with zero (in the shared project "buildTarget") and said enum value does not exist for type BuildTarget, the PropertyField does not know what to select. To avoid problems, initialize the member with a valid value, for example:
[SerializeField]
private BuildTarget buildTarget = BuildTarget.NoTarget;
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
- Object Picker does not open when a reference is in an array and is clicked on through a non-standard pointer (tablet pen, touchscreen)
- HDRP ShaderGraph Color property gets overridden when it is named "EmissionColor"
- Material properties are lost when setting a parent that hasn't been loaded yet
- NullReferenceException is thrown when creating State from a Selected Clip if that Clip is a Blend Tree
- Built Player with Vulkan Graphics API hangs/freezes when VSync is enabled and "Run In Background" is enabled
Resolution Note (fix version 2021.2):
UI Toolkit: Fixes 1304581: [UIElements] ArgumentException is thrown when the PropertyField is bind to the BuildTarget enum
Popup/Dropdown (Enum-compatible) fields now gracefully handle unselected/invalid values.
Fixed in: 2021.2.0a5
Resolution Note (fix version 2020.3):
Fixed in: 2020.3.25f1