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
- Required SpriteMask class (ID 331) is stripped when "Strip Engine Code" is enabled
- “Maximized serialized file backup not found” error is thrown when minimizing a window in a newly opened project
- Build stack trace contains invalid lines when building with IL2CPP using scripts with delegates containing generic types in the signature
- Entities Systems window has a “Show Full Player Loop” dropdown which does nothing when clicked after enabling “Show Full Player Loop”
- Entities Hierarchy Search “Show/Hide” button’s Lens Icon is blurry when the Editor is on an external monitor
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.