Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Exception when right clicking for context menu on scene hierarchy

Discussion in 'Editor & General Support' started by skydestinies, Aug 10, 2022.

  1. skydestinies

    skydestinies

    Joined:
    Feb 6, 2014
    Posts:
    19
    I'm using Unity 2021.3.7f1
    I get this error whenever I try to right click to get the creation context menu in my scene hierarchy. It doesn't seem to have any indicators for where in custom editor code it might be getting this exception. Any ideas for how to troubleshoot this?
    Thanks

    Code (CSharp):
    1. ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
    2. Parameter name: startIndex
    3. System.String.Substring (System.Int32 startIndex, System.Int32 length) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0)
    4. System.String.Substring (System.Int32 startIndex) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0)
    5. UnityEditor.SceneHierarchy.AddCreateGameObjectItemsToMenu (UnityEditor.GenericMenu menu, UnityEngine.Object[] context, System.Boolean includeCreateEmptyChild, System.Boolean useCreateEmptyParentMenuItem, System.Boolean includeGameObjectInPath, System.Int32 targetSceneHandle, UnityEditor.MenuUtils+ContextMenuOrigin origin) (at <33518779906b403ba9f96eccba6a861b>:0)
    6. UnityEditor.SceneHierarchy.CreateGameObjectContextClick (UnityEditor.GenericMenu menu, System.Int32 contextClickedItemID) (at <33518779906b403ba9f96eccba6a861b>:0)
    7. UnityEditor.SceneHierarchy.ItemContextClick (System.Int32 contextClickedItemID) (at <33518779906b403ba9f96eccba6a861b>:0)
    8. UnityEditor.IMGUI.Controls.TreeViewController.HandleUnusedMouseEventsForItem (UnityEngine.Rect rect, UnityEditor.IMGUI.Controls.TreeViewItem item, System.Int32 row) (at <33518779906b403ba9f96eccba6a861b>:0)
    9. UnityEditor.IMGUI.Controls.TreeViewController.DoItemGUI (UnityEditor.IMGUI.Controls.TreeViewItem item, System.Int32 row, System.Single rowWidth, System.Boolean hasFocus) (at <33518779906b403ba9f96eccba6a861b>:0)
    10. UnityEditor.IMGUI.Controls.TreeViewController.IterateVisibleItems (System.Int32 firstRow, System.Int32 numVisibleRows, System.Single rowWidth, System.Boolean hasFocus) (at <33518779906b403ba9f96eccba6a861b>:0)
    11. UnityEditor.IMGUI.Controls.TreeViewController.OnGUI (UnityEngine.Rect rect, System.Int32 keyboardControlID) (at <33518779906b403ba9f96eccba6a861b>:0)
    12. UnityEditor.SceneHierarchy.DoTreeView (System.Single searchPathHeight) (at <33518779906b403ba9f96eccba6a861b>:0)
    13. UnityEditor.SceneHierarchy.OnGUI (UnityEngine.Rect rect) (at <33518779906b403ba9f96eccba6a861b>:0)
    14. UnityEditor.SceneHierarchyWindow.DoSceneHierarchy () (at <33518779906b403ba9f96eccba6a861b>:0)
    15. UnityEditor.SceneHierarchyWindow.OnGUI () (at <33518779906b403ba9f96eccba6a861b>:0)
    16. UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <33518779906b403ba9f96eccba6a861b>:0)
    17. UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <33518779906b403ba9f96eccba6a861b>:0)
    18. UnityEditor.DockArea.OldOnGUI () (at <33518779906b403ba9f96eccba6a861b>:0)
    19. 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 <7f157a18f174494d95b4f32b68f44272>:0)
    20. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7f157a18f174494d95b4f32b68f44272>:0)
    21. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7f157a18f174494d95b4f32b68f44272>:0)
    22. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <7f157a18f174494d95b4f32b68f44272>:0)
    23. UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <7f157a18f174494d95b4f32b68f44272>:0)
    24. UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <7f157a18f174494d95b4f32b68f44272>:0)
    25. UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <7f157a18f174494d95b4f32b68f44272>:0)
    26. UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <7f157a18f174494d95b4f32b68f44272>:0)
    27. UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToRegularTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7f157a18f174494d95b4f32b68f44272>:0)
    28. UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7f157a18f174494d95b4f32b68f44272>:0)
    29. UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel iPanel) (at <7f157a18f174494d95b4f32b68f44272>:0)
    30. UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <7f157a18f174494d95b4f32b68f44272>:0)
    31. UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7f157a18f174494d95b4f32b68f44272>:0)
    32. UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7f157a18f174494d95b4f32b68f44272>:0)
    33. UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7f157a18f174494d95b4f32b68f44272>:0)
    34. UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7f157a18f174494d95b4f32b68f44272>:0)
    35. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <7f157a18f174494d95b4f32b68f44272>:0)
    36. UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <7f157a18f174494d95b4f32b68f44272>:0)
    37. UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <7f157a18f174494d95b4f32b68f44272>:0)
    38. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <45a3ca8ab7454d7689470d39a3e915d0>:0)
    39.  
     
  2. Knbmedia

    Knbmedia

    Joined:
    Dec 8, 2014
    Posts:
    18
    Hi
    Did you find a solution? I get the same problem when updating from 2020 to 2021.3.7f1.
    I tried to update to 2021.3.9f1 but the problem still occurs.
    I found on the web some posts about uninstalling TextMeshPro: it works but when reinstalling it, the problem occurs again.
    Thanks

    EDIT:
    Finally, I found that an Editor script from on old asset was causing this strange bug.
    No idea why. I found this Editor script when removing all my Unity assets one by one...
     
    Last edited: Sep 8, 2022