Search Issue Tracker
By Design
Votes
0
Found in
2022.3.59f1
6000.0.40f1
6000.1.0b8
6000.2.0a5
6000.3.0a1
Issue ID
UUM-98307
Regression
No
EditorGUILayout.PropertyField foldout icon inside Vertical Layout Group has an incorrect indent when used with OnInspectorGUI()
Reproduction steps:
1. Open the attached “IN-95640.zip” project
2. Open the “SampleScene”
3. From the Hierarchy, select the “Test” GameObject
4. Observe the “Test Component Bug (Script)” Component in the Inspector
Expected result: The foldout icon is inside the “Box” container and is correctly indented
Actual result: The foldout icon is indented not correctly and is outside of the “Box” container
Reproducible with: 2022.3.59f1, 6000.0.40f1, 6000.1.0b8, 6000.2.0a5
Reproducible on: Windows 11
Not reproducible on: No other environment tested
Note:
- The expected result can be seen in the “Test Component Working (Script)” Component, which uses “CreateInspectorGUI()”
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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
Resolution Note:
When you use OnInspectorGUI in your editor, we know you are working with IMGUI code. Internally, we create an IMGUIContainer and wrap your IMGUI calls with additional setup and teardown code to ensure the IMGUI state aligns with the inspector. However, when you use CreateInspectorGUI, we expect UI Toolkit elements to be returned. In this case, IMGUIContainer does not have the necessary context to recognize it is part of the inspector, so it defaults to standard values.
For this specific use case (the foldout issue), it can be fixed by setting EditorGUIUtility.hierarchyMode = true. Alternatively, a workaround would be to use two InspectorElement instances: one for UI Toolkit elements and another to handle the IMGUI drawing. This approach allows you to keep the responsibilities of each framework separate while avoiding the context mismatch.
Unfortunately, it is challenging for us to change this behaviour now, as it would almost certainly break existing editor tools that have been written around the current behaviour.