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
- 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:
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;
}
}