BUG? State Inspector Helper Game Objects Appearing

Badamb

New member
Ultimate Character Controller Version 2.3.1
Unity Version 2021.1.1f1

Whenever I click on one of my character assets I get seven New Game Objects appearing in the hierarchy. They all have the State Inspector Helper script. They then keep spawning if I keep the asset selected.

Sorry it's a bit vague but this other thread explains it well:

 
I haven't been able to reproduce it from that thread - if you can let me know how to reproduce from a fresh project that would be great.
 
Hi Justin,

I started a fresh project and imported the same character asset. I noticed it only happens if the character is selected and if the Attribute Manager Script is expanded in the inspector.

I noticed with the fresh project that I was getting the following error each time the New Game Object was spawned:

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Editor.Inspectors.Traits.AttributeManagerInspector.OnAttributeStateListDraw (UnityEngine.Rect rect, System.Int32 index, System.Boolean isActive, System.Boolean isFocused) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Traits/AttributeManagerInspector.cs:268)
UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:995)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:774)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at /Users/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:758)
Opsive.Shared.Editor.Inspectors.StateSystem.StateInspector.DrawStates (UnityEditorInternal.ReorderableList reorderableList, UnityEditor.SerializedObject serializedObject, UnityEditor.SerializedProperty states, System.String selectedIndexKey, UnityEditorInternal.ReorderableList+ElementCallbackDelegate drawCallback, UnityEditorInternal.ReorderableList+AddCallbackDelegate addCallback, UnityEditorInternal.ReorderableList+ReorderCallbackDelegate reorderCallback, UnityEditorInternal.ReorderableList+RemoveCallbackDelegate removeCallback) (at Assets/Opsive/Shared/Editor/Inspectors/StateSystem/StateInspector.cs:84)
Opsive.UltimateCharacterController.Editor.Inspectors.Traits.AttributeManagerInspector.DrawSelectedAttribute (System.Int32 index) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Traits/AttributeManagerInspector.cs:243)
Opsive.UltimateCharacterController.Editor.Inspectors.Utility.ReorderableListSerializationHelper.DrawReorderableList (UnityEditorInternal.ReorderableList& reorderableList, Opsive.Shared.Editor.Inspectors.InspectorBase inspector, System.Array drawnObject, System.String serializedData, UnityEditorInternal.ReorderableList+HeaderCallbackDelegate drawHeaderCallback, UnityEditorInternal.ReorderableList+ElementCallbackDelegate drawElementCallback, UnityEditorInternal.ReorderableList+ReorderCallbackDelegate reorderCallback, UnityEditorInternal.ReorderableList+AddCallbackDelegate addCallback, UnityEditorInternal.ReorderableList+RemoveCallbackDelegate removeCallback, UnityEditorInternal.ReorderableList+SelectCallbackDelegate selectCallback, System.Action`1[T] drawSelectedElementCallback, System.String key, System.Boolean requireOne, System.Boolean indentList) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Utility/ReorderableListSerializationHelper.cs:91)
Opsive.UltimateCharacterController.Editor.Inspectors.Traits.AttributeManagerInspector.OnInspectorGUI () (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Traits/AttributeManagerInspector.cs:52)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Editor/Inspector/InspectorElement.cs:617)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)


Hope that's of some use!
 
That error is likely the reason for the empty GameObjects. Can you send the scene to support@opsive.com that is causing the error? I created a fresh scene in a new project and after creating the character I didn't get that error.
 
Did they ever send you that scene? I have this happen occasionally. I've just been deleting them, then came here to check to make sure it was *ok* that I was deleting them, lol. Happens very rarely for me, so no idea how to reproduce.
 
I never received a repro project but think I narrowed down the cause. This is caused by an exception being thrown in another script while the state inspector is drawing. In the next update I included the code in a try/catch block and it cleans up after itself so hopefully it'll be fixed.
 
This should no longer be an issue in the latest version. If you have confirmed that you are running the latest and can list the steps to reproduce that would be helpful.
 
This issue is currently happening to me. I'm using the latest version of TPC. I can recreate by just going into the Demo and click on the Nolan Character game object, it will then spawn in 7 new game objects with the State Inspector Helper Script. Clicking on the one of the game objects and then back on Nolan, will cause it to spawn more as well. It will also just continue to spawn if I just leave it on there for a bit and click around in the editor, for example clicking on the errors.

NullReferenceException: Object reference not set to an instance of an object Opsive.UltimateCharacterController.Editor.Inspectors.Inventory.ItemSetManagerBaseInspector.OnItemSetStateListDraw (UnityEngine.Rect rect, System.Int32 index, System.Boolean isActive, System.Boolean isFocused) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Inventory/ItemSetManagerBaseInspector.cs:470) UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at <ac4382394009481fa61779d0ab47a96f>:0) UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <ac4382394009481fa61779d0ab47a96f>:0) UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at <ac4382394009481fa61779d0ab47a96f>:0) Opsive.Shared.Editor.Inspectors.StateSystem.StateInspector.DrawStates (UnityEditorInternal.ReorderableList reorderableList, UnityEditor.SerializedObject serializedObject, UnityEditor.SerializedProperty states, System.String selectedIndexKey, UnityEditorInternal.ReorderableList+ElementCallbackDelegate drawCallback, UnityEditorInternal.ReorderableList+AddCallbackDelegate addCallback, UnityEditorInternal.ReorderableList+ReorderCallbackDelegate reorderCallback, UnityEditorInternal.ReorderableList+RemoveCallbackDelegate removeCallback) (at Assets/Opsive/Shared/Editor/Inspectors/StateSystem/StateInspector.cs:83) Opsive.UltimateCharacterController.Editor.Inspectors.Inventory.ItemSetManagerBaseInspector.DrawSelectedItemSet (Opsive.UltimateCharacterController.Inventory.ItemSet itemSet, System.Int32 index) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Inventory/ItemSetManagerBaseInspector.cs:442) Opsive.UltimateCharacterController.Editor.Inspectors.Inventory.ItemSetManagerBaseInspector.OnInspectorGUI () (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Inventory/ItemSetManagerBaseInspector.cs:101) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <777f1e2f196a4d68b6a430f207e1229a>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
 
Do you get that error in a fresh project? I just tried it and wasn't able to reproduce.
 
Are you using the ThirdPersonControllerDemo and not the UltimateCharacterControllerDemo?
 
I created a new project with Unity 2021.2, imported TPC from the Asset Store, installed the Unity Package, and clicked on Nolan from the ThirdPersonControllerDemo. There weren't any errors.

Line 470 of ItemSetManagerBaseInspector points to:

Code:
                m_ReorderableItemSetStateList[m_ItemSetListIndex].index = -1;
 
Hmmm I'm not sure why it's not affecting you, I tried it again deleting all Opsive Asset Files and redownloading from Package Manager and create a new project in Unity 2021.2.0, imported TPC, installed Unity Package, and clicked on Nolan from ThirdPersonControllerDemo and I get the same error. I'm using Windows 11, not sure if that would matter or not. Only other thing I could think of that might be different.
 
That is a preference that is saved so it's probably why it's not affecting me. Did you remove the line that is causing the error?
 
I now have this bug on 2021.3f1 LTS, fresh import of UCC 2.4.8 version (as in I deleted the Opsive folder and reimported everything). It's in the demo scene, I just click on the Nolan character and it spams New Game Objects. It only stops when I collapse all inspector components. It's URP pipeline version if that makes any difference, there's also this error below. After I remove that line mentioned by the poster in this thread it fixes it, but why is it there in the first place?

Also inspector scrolling on a Nolan character with all components expanded is much slower on 2021.3 LTS, although I'm guessing its probably Unity's fault, sigh...

C#:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Editor.Inspectors.Inventory.ItemSetManagerBaseInspector.OnItemSetStateListDraw (UnityEngine.Rect rect, System.Int32 index, System.Boolean isActive, System.Boolean isFocused) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Inventory/ItemSetManagerBaseInspector.cs:536)
UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at <780782bc035845f9909cebbd4c983ae3>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <780782bc035845f9909cebbd4c983ae3>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at <780782bc035845f9909cebbd4c983ae3>:0)
Opsive.Shared.Editor.Inspectors.StateSystem.StateInspector.DrawStates (UnityEditorInternal.ReorderableList reorderableList, UnityEditor.SerializedObject serializedObject, UnityEditor.SerializedProperty states, System.String selectedIndexKey, UnityEditorInternal.ReorderableList+ElementCallbackDelegate drawCallback, UnityEditorInternal.ReorderableList+AddCallbackDelegate addCallback, UnityEditorInternal.ReorderableList+ReorderCallbackDelegate reorderCallback, UnityEditorInternal.ReorderableList+RemoveCallbackDelegate removeCallback) (at Assets/Opsive/Shared/Editor/Inspectors/StateSystem/StateInspector.cs:83)
Opsive.UltimateCharacterController.Editor.Inspectors.Inventory.ItemSetManagerBaseInspector.DrawSelectedItemSet (Opsive.UltimateCharacterController.Inventory.ItemSet itemSet, System.Int32 index) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Inventory/ItemSetManagerBaseInspector.cs:506)
Opsive.UltimateCharacterController.Editor.Inspectors.Inventory.ItemSetManagerBaseInspector.OnInspectorGUI () (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Inventory/ItemSetManagerBaseInspector.cs:110)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <3d6ac16e3c754a199373804b462a1b72>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
 

Attachments

  • bug.png
    bug.png
    108.4 KB · Views: 5
+1 I have the same issue. Regardless of pipeline. I figure it has to do with unity screwing up the reorderable lists, yet again
 
The error that you are receiving is the cause. What is null on 536 of ItemSetManagerBaseInspector? If you do an EditorPrefs.DeleteAll does it fix the issue?
 
Top