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
- [OpenGLES][XR] Zooming in on the camera's URP opaque texture causes "double vision" on Quest in OpenGLES3
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
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