Search Issue Tracker
By Design
Votes
0
Found in
2022.3.35f1
6000.0.8f1
Issue ID
UUM-74713
Regression
Yes
Prefab components are not rendered correctly in the Inspector Window when "HideFlags.HideInInspector" is used
Reproduction Steps:
1. Open the attached project “BugRepro”
2. Open {{Assets/Scenes/SampleScene.unity}}
3. Click on the {{Cube (prefab)}} GameObject in the Hierarchy
4. Notice that the Box Collider is not displaying its contents when expanded (i.e., it remains collapsed)
5. Click on the {{Cube (non-prefab)}} GameObject in the Hierarchy
6. Notice that the Box Collider expands properly
Expected Result: The Box Collider component is expanded and displays its properties
Actual Result: The Box Collider is collapsed and not expandable
Reproducible with: 2022.1.0a15, 2022.3.35f1, 6000.0.8f1
Not reproducible with: 2021.3.40f1, 2022.1.0a14
Note: If the repro is not working, try reloading the scene (load New Scene, then SampleScene again)
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
- “Client And Server” shown without spaces in Active Scenario window
- [Linux] Mouse cursor gets stuck at the edge of the screen when trying to pan in the Scene view
- Docked Multiplayer Play Mode window disappears when switching back to a saved Editor layout
- Audio files fail to be imported when the file path is 260 characters or longer
- Error SGICE002 is wrongly shown when more than one argument is passed into GetComponentRW()
Resolution Note:
The bisected PR related to time slicing in the Inspector ensures better system responsiveness. The reported error is inconsistent due to interference with the Inspector's responsiveness. Instead of altering the Inspector's behaviour, we optimized the user script:
Caching the Target Component: Instead of using FindObjectOfType, which searches the entire scene, directly cast the target property to your component in OnEnable. This ensures you're working directly with the component attached to the inspected object.
Setting hideFlags in OnEnable: Setting HideFlags.HideInInspector once in OnEnable ensures it's applied when the Inspector is first enabled, rather than repeatedly in OnInspectorGUI.
After hiding the component from the Inspector, users can still access it via debug mode for script manipulation.
User-provided Script:
[CustomEditor(typeof(ExampleComponent))]
public class HideInInspectorExample : Editor
{
public override void OnInspectorGUI()
{
var myComponent = FindObjectOfType<ExampleComponent>();
myComponent.hideFlags = HideFlags.HideInInspector;
base.OnInspectorGUI();
}
}
Modified script:
[CustomEditor(typeof(ExampleComponent))]
public class HideInInspectorExample : Editor
{
private ExampleComponent myComponent;
private void OnEnable()
{
myComponent = (ExampleComponent)target;
myComponent.hideFlags = HideFlags.HideInInspector;
}
}