[Bug] Camera Controller View Type list and Ultimate Character Locomotion Movement Type list is very buggy on the inspector

mkoala

New member
Hello, I've found that the View Type list on the Camera Controller and Movement Type list on the Ultimate Character Locomotion scripts very buggy.

To replicate (replication steps are done on prefabs):
  • Create a camera with both perspectives (e.g. First Person Combat and Third Person Adventure)
  • Create a character with both perspectives (e.g. First Person Combat and Third Person Adventure)
  • Decide to change Third Person Adventure to Third Person Combat in the Camera Controller. First Bug: Click on the plus icon and the bug should show. The newly added view type is not visible on the list but somehow it is added in the background.
  • Second Bug: Try to workaround the problem by clicking on another GameObject and then back to the Camera Controller (to reset the inspector and redraw the fields). You now notice that there are 3 view types, this includes the Third Person Combat you just added. Press the minus icon and delete the Third Person Adventure view type. This now breaks the inspector and error on the console shows:
[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]IndexOutOfRangeException: Index was outside the bounds of the array.[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.GetElementHeight (System.Int32 index) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:681)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.GetClampedDragPosition (UnityEngine.Rect listRect) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:1337)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.CalculateRowIndex (UnityEngine.Rect listRect) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:1342)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.DoDraggingAndSelection (UnityEngine.Rect listRect) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:1244)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:980)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:745)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at /home/bokken/buildslave/unity/build/Editor/Mono/GUI/ReorderableList.cs:729)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]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, System.Boolean useSerializedData) (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Utility/ReorderableListSerializationHelper.cs:94)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]Opsive.UltimateCharacterController.Editor.Inspectors.Camera.CameraControllerInspector.<GetDrawCallback>b__13_0 () (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Camera/CameraControllerInspector.cs:150)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]Opsive.Shared.Editor.Inspectors.StateSystem.StateBehaviorInspector.OnInspectorGUI () (at Assets/Opsive/Shared/Editor/Inspectors/StateSystem/StateBehaviorInspector.cs:92)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Editor/Inspector/InspectorElement.cs:636)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /home/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)[/INDENT][/INDENT][/INDENT][/INDENT] [INDENT=2][INDENT=2][INDENT=2][INDENT=2]
  • Now change Movement Type on the Ultimate Character Locomotion from Third Person Adventure to Third Person Combat. Click the plus icon to add a new Movement Type. Click the Third Person Adventure Movement Type and press the minus icon to delete it from the list. Third Bug: Notice the Third Person Movement Type automatically changes to Combat. Press play and change to third person perspective and an error will show that Ultimate Character Locomotion cannot find the Adventure Movement Type. Inspect the prefab as text in your IDE and search for "Adventure". You'll find that the value for Third Person Movement Type is still set to the old value of Third Person Adventure. Even though the inspector automatically shows Combat, the prefab is actually not updated with the value.

I'm guessing there is an issue on the logic of how the custom inspector is drawn. Of course, you can workaround this problem by just creating a brand new camera or character with the correct view/movement type settings but this would be a huge pain if you've already set up a lot of custom scripts on the prefabs, you basically have to set them up again.

Forgot to mention that this on the latest LTS version: Unity 2021.3.2f1
 
Last edited:

Justin

Administrator
Staff member
This looks related to this post:


Unity's inspector has made some internal changes. I have this fixed and will be submitting a new version shortly. I will send you a PM with the fixed files.
 

mkoala

New member
Hi, @Justin. I noticed that the UCC 2.4.8 release fixed the issue with the reorderable lists but the bug in the dropdowns for the Movement Type on the Ultimate Character Locomotion script still persists, stated as the second bug on my post. The automatic switching of the value is only visual and it still holds the old value. You can quickly see this by using the debug mode of the inspector and check the value of "Third Person Movement Type Full Name". I haven't tried it with the first person perspective but I'm assuming it's the same.

Not a huge deal breaker though unlike the reorderable list which I'm very thankful for the quick fix.
 

Justin

Administrator
Staff member
Can you list the steps to reproduce? I tried it in a fresh project and didn't have a problem switching view types. From your original post number 2 relates to the view types.
 

mkoala

New member
To reproduce:

  1. Create new project and import UCC 2.4.8. Set up the scene by adding UCC managers.
  2. Set up camera by setting the perspective to "Both". As an example, the first person view type is "combat" while the third person view type is also "combat"
  3. Create a character with "both" perspectives. Movement type for first person is "combat" and third person is "combat"
  4. On the Ultimate Character Locomotion script, add a new movement type of "third person adventure". Click on the radio button for "third person adventure" to make it active. Notice the Third Person Movement Type value above, it automatically changes to "Adventure". Change to the debug mode of the inspector and confirm that the value of Third Person Movement Type Full Name is set to "adventure".
  5. Go back to inspector normal mode. While highlighting the "third person adventure" movement type, click on the minus icon to delete it. Notice the Third Person Movement Type changes back to "Combat" automatically. Change inspector to debug mode again, the value of Third Person Movement Type Full Name is still set to "adventure".
  6. You can confirm that the issue persists by entering play mode. An error will pop up "Unable to find the movement type with name Opsive.UltimateCharacterController.ThirdPersonController.Character.MovementTypes.Adventure." when trying to switch perspectives.
To summarize, the value of the Third Person Movement Type Full Name does not reset when deleting an active movement type. It retains its old value (which was already deleted) causing errors during runtime.

I can confirm that this happens on the First Person Movement Type Full Name too.

Note: This doesn't happen on the camera controller's view type. Only on the Ultimate Character Locomotion's movement type. Probably just forgot to reset the value on delete. Though I did notice that adding a new view type changes the perspective dropdown but for some reason the value does not refresh unless you click on another object and then back to the camera controller. You can check the debug mode of the inspector for this, a very minor bug on the camera controller's view type.
 

Justin

Administrator
Staff member
Thanks! With those steps I was able to reproduce it. I have it fixed for the next update.
 
Top