title: I'm trying to use ReorderableList in Inspector but it's not working good. How should I work with it?
body: <p>The editor script.</p>
  
  <p>The problem is that I see in the ReorderableList items from index 0 to 17 and then many more item but they are all Missing. And when trying to delete them they are not deleted.</p>
  
  <p>I want to add new items using the MenuItem and the Selection.
  I want to add more propertied to per item like Undo so Undo will remove from the gameobject in the list the  BoxCollider and the script Whilefun.FPEKit.FPEInteractablePickupScript</p>
  
  <p>The idea is that when I select an gameobject in the hierarchy if I'm doing right click and select Generate as Pickup Item only then add the BoxCollider and the script Whilefun.FPEKit.FPEInteractablePickupScript and only then add that selected gameobject as item to the ReorderableList and if I make in the ReorderableList on one of them items right click with the mouse and select undo then first remove the Box Collider and the Whilefun.FPEKit.FPEInteractablePickupScript and then remove the gameobject item from the ReorderableList.</p>
  
  <pre><code>using System;
  using System.Collections;
  using System.Collections.Generic;
  using UnityEditor;
  using UnityEditorInternal;
  using UnityEngine;
  
  [CustomEditor(typeof(PickupObjects))]
  public class PickupObjectsEditor : Editor
  {
      private static List&lt;GameObject&gt; pickeditems = new List&lt;GameObject&gt;();
      private static bool picked = false;
  
      [MenuItem("GameObject/Generate as Pickup Item", false, 30)]
      public static void GeneratePickupItems()
      {
          if (Selection.gameObjects.Length &gt; 0)
          {
              pickeditems.Clear();
  
              for (int i = 0; i &lt; Selection.gameObjects.Length; i++)
              {
                  if (Selection.gameObjects[i].GetComponent&lt;Whilefun.FPEKit.FPEInteractablePickupScript&gt;() == null)
                  {
                      Selection.gameObjects[i].AddComponent&lt;BoxCollider&gt;();
                      Selection.gameObjects[i].AddComponent&lt;Whilefun.FPEKit.FPEInteractablePickupScript&gt;();
                  }
  
                  Selection.gameObjects[i].layer = 9;
                  Selection.gameObjects[i].tag = "Pickup Item";
  
                  pickeditems.Add(Selection.gameObjects[i]);
              }
  
              picked = true;
          }
      }
  
      PickupObjects _target;
  
      private ReorderableList _myList;
  
      public void OnEnable()
      {
          _target = (PickupObjects)target;
  
          _myList = new ReorderableList(serializedObject, serializedObject.FindProperty("pickUpObjects"), true, true, true, true);
  
          _myList.drawHeaderCallback = rect =&gt;
          {
              EditorGUI.LabelField(rect, "My Reorderable List", EditorStyles.boldLabel);
          };
  
          _myList.drawElementCallback =
              (Rect rect, int index, bool isActive, bool isFocused) =&gt;
              {
                  var element = _myList.serializedProperty.GetArrayElementAtIndex(index);
                  EditorGUI.ObjectField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
              };
      }
  
      public override void OnInspectorGUI()
      {
          serializedObject.Update();
          _myList.DoLayoutList();
          serializedObject.ApplyModifiedProperties();
      }
  }
  </code></pre>
  
  <p>And the mono script</p>
  
  <pre><code>using System.Collections.Generic;
  using UnityEditor;
  using UnityEngine;
  
  public class PickupObjects : MonoBehaviour
  {
      public List&lt;GameObject&gt; pickUpObjects = new List&lt;GameObject&gt;();
  }
  </code></pre>
  
  <p>This is a screenshot of the ReorderableList. All messed :</p>
  
  <p><a href="https://i.stack.imgur.com/Lf1Uh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lf1Uh.jpg" alt="ReorderableList in the inspector"></a></p>