HierarchyDecorator
HierarchyDecorator copied to clipboard
Bug - Exceptions occrued and hierarchy is hidden caused by a specific operations.
Current Unity version used 2023.2.15f1
Describe the bug Following exception occured and objects in hierarchy view is hidden.
MissingReferenceException: The object of type 'UnityEngine.Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <123ecbb0004d46b4bbbd5457b343f3c5>:0)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <123ecbb0004d46b4bbbd5457b343f3c5>:0)
UnityEngine.Transform.get_childCount () (at <123ecbb0004d46b4bbbd5457b343f3c5>:0)
HierarchyDecorator.BreadcrumbsDrawer.DrawInternal (UnityEngine.Rect rect, UnityEngine.GameObject instance, HierarchyDecorator.Settings _settings) (at Assets/HierarchyDecorator/Scripts/Editor/Hierarchy/Drawers/BreadcrumbsDrawer.cs:43)
HierarchyDecorator.HierarchyDrawer.Draw (UnityEngine.Rect rect, UnityEngine.GameObject instance, HierarchyDecorator.Settings settings) (at Assets/HierarchyDecorator/Scripts/Editor/Hierarchy/HierarchyDrawer.cs:21)
HierarchyDecorator.HierarchyDecorator.OnHierarchyItem (System.Int32 instanceID, UnityEngine.Rect selectionRect) (at Assets/HierarchyDecorator/Scripts/Editor/HierarchyDecorator.cs:122)
UnityEditor.GameObjectTreeViewGUI.UserCallbackRowGUI (System.Int32 itemID, UnityEngine.Rect rect) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.SceneHierarchy.OnRowGUICallback (System.Int32 itemID, UnityEngine.Rect rect) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.IMGUI.Controls.TreeViewController.DoItemGUI (UnityEditor.IMGUI.Controls.TreeViewItem item, System.Int32 row, System.Single rowWidth, System.Boolean hasFocus) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.IMGUI.Controls.TreeViewController.IterateVisibleItems (System.Int32 firstRow, System.Int32 numVisibleRows, System.Single rowWidth, System.Boolean hasFocus) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.IMGUI.Controls.TreeViewController.OnGUI (UnityEngine.Rect rect, System.Int32 keyboardControlID) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.SceneHierarchy.DoTreeView (System.Single searchPathHeight) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.SceneHierarchy.OnGUI (UnityEngine.Rect rect) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.SceneHierarchyWindow.DoSceneHierarchy () (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.SceneHierarchyWindow.OnGUI () (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEditor.DockArea.OldOnGUI () (at <ef6d5d4ea4aa484c9d9bb0be4865c768>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <68805bd66dea42d3b55c1c424f97b7bc>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
To Reproduce (If applicable)
- Press Play button.
- Search through the Search field for a specific object (probably must be an one generated at runtime).
- Click on the object in the search results to focus.
- Click the x in the right marker of the Search field to turn off the filter.
- Exit PlayMode by press Play button.
- Exception Occurs.
- It is caused by the use of search fields.
- There is a specific game object that causes the occurrence. Not all game objects are affected. I don't know what they have in common.
- Cannot be reproduced in the sample scenes in this library.
This is a simple but workaround code. It is not a radical solution, but at least it does not raise an exception, so the hierarchy view does not disappear.