ArgumentException: Getting control 19's position in a group with only 19 controls when doing dragPerform Aborting
So I have this all set up in the inspector:
but if the waypoints list is at 0 and I manually drag something in I get:
ArgumentException: Getting control 19's position in a group with only 19 controls when doing dragPerform Aborting UnityEngine.GUILayoutGroup.GetNext () (at :0) > UnityEngine.GUILayoutUtility.DoGetRect > (UnityEngine.GUIContent content, > UnityEngine.GUIStyle style, > UnityEngine.GUILayoutOption[] options) > (at > :0) > UnityEngine.GUILayoutUtility.GetRect > (UnityEngine.GUIContent content, > UnityEngine.GUIStyle style, > UnityEngine.GUILayoutOption[] options) > (at > :0) > UnityEngine.GUILayout.DoButton > (UnityEngine.GUIContent content, > UnityEngine.GUIStyle style, > UnityEngine.GUILayoutOption[] options) > (at > :0) > UnityEngine.GUILayout.Button > (System.String text, > UnityEngine.GUILayoutOption[] options) > (at > :0) > Handlers.Pathing_Handler.PathingHandlerEditorButtons.OnInspectorGUI > () (at Assets/Scripts/Handlers/Pathing > Handler/PathingHandlerEditorButtons.cs:22) > UnityEditor.UIElements.InspectorElement+<>c_DisplayClass58_0.b_0 () (at > :0) > UnityEngine.GUIUtility:ProcessEvent(Int32, > IntPtr)
This is the CustomEditor code:
using UnityEngine;
using UnityEditor;
namespace Handlers.Pathing_Handler {
[CustomEditor(typeof(PathingHandler))]
public class PathingHandlerEditorButtons : Editor {
private PathingHandler _pathingHandler;
private void OnEnable() {
_pathingHandler = target as PathingHandler;
}
public override void OnInspectorGUI() {
base.OnInspectorGUI();
if (GUILayout.Button("Add Child Objects As Waypoints")) _pathingHandler.AddChildObjectsAsWaypoints(false);
if (_pathingHandler.waypoints == null || _pathingHandler.waypoints.Count <= 0) return;
if (_pathingHandler.WaypointsListContainsNull) {
if (GUILayout.Button("Remove Null Values From Waypoints"))
_pathingHandler.RemoveNullWaypointsFromWaypointsList();
}
if (_pathingHandler.WaypointsListHasDuplicates) {
if (GUILayout.Button("Remove Duplicates From Waypoints"))
_pathingHandler.RemoveDuplicateWaypointsFromWaypointsList();
}
if (GUILayout.Button("Clear All Waypoints")) _pathingHandler.ClearWaypointsList();
}
}
}
I know the issue is here somewhere because whenever I comment all that code out I don't get the error. If anybody knows what I can do to fix this it'd help a lot!