title: how to remove a specific game object (that is in an array) from a list?
body: <p>my goal with the code is to have multiple skulls appear on screen for comparison. Depending on number of skulls on screen (1-6) they change position and size, Ive done this through the use of an array of gameObjects (the skulls) and a list that can keep track of which skull is in which "position".</p>
  
  <p>The code works if you are adding, but runs into problems when you remove the object. It "works" on <em>RemoveAt</em> only if you remove the GameObjects in the same order that they were added. IE: The list is always removing <em>element 0</em>(first item in list) rather than the specific gameObject that is instigating the <em>RemoveAt</em> function.</p>
  
  <p>While I have found many answers on how to remove specific individual gameObjects, They dont work since my gameObjects are in an array- I cant simply say <em>remove gameObject name</em>. Which leads me to my question of how to remove a specific gameObject[] from a list?</p>
  
  <p>either <em>remove</em> or <em>removeAll</em> run these two errors:</p>
  
  <p><em>error CS1502:</em> The best overloaded method match for <code>System.Collections.Generic.List&lt;UnityEngine.GameObject&gt;.RemoveAll(System.Predicate&lt;UnityEngine.GameObject&gt;)' has some invalid arguments.<br>
  Error CS1503: Argument</code>#1' cannot convert <code>int' expression to type</code>System.Predicate'</p>
  
  <p>Here are my two scripts for all this: </p>
  
  <p>Script on each bird skull named <em>birdController</em>:</p>
  
  <pre><code>public int myBirdID;
  public int orderInList;
  
  //bool to keep track of object active or not
  public bool whoAmIReally;
  //potentially redundant; allows game object to see if hes on or not
  public GameObject IAmMe;
  
  // Use this for initialization
  void Start () {
      //fixingIntOrder();
  }
  
  public void OnEnable(){
      //when object is on check bool
          whoAmIReally = true;
          Debug.Log("IM ON");
  }
      public void OnDisable(){
      //when object is turned off uncheck bool, change list value to 0
              //**this wont change actual list order or value in cubeplacement script- my hope is that it might have- likely missing a step somewhere
          whoAmIReally = false;
          orderInList = 0;
          Debug.Log("IMOFF");
  }
  </code></pre>
  
  <p>Script on empty with all of my array and list info named <em>cubePlacement</em>:</p>
  
  <pre><code>    public int numberSkullOnScreen;
      public bool[] skullOn;
      public GameObject[] allSkulls;
  
      public GameObject listHolder;
  
      public List&lt;GameObject&gt; birdsOnScreen = new List&lt;GameObject&gt;();
  
  
  //declaring the script to avoid NullReferenceEcxeption where I reference it 
  public birdController _birdController;
  
  
      // Use this for initialization
      void Start () {
          //only way I can get my list to work: have an object act as a placeholder onStart
          birdsOnScreen.Add(listHolder);
      }
  
  //turning on and off the skulls
      public void toggleBirdSkull(int mySkull){
          if (skullOn[mySkull] == false){
              //set specific gameObject active
              allSkulls[mySkull].SetActive(true);
              //make skull on bool true 
              skullOn[mySkull] = true;
              //add one to the number on screen
              numberSkullOnScreen++;
  
              //reference int orderInList from Bird controller script
              allSkulls[mySkull].gameObject.GetComponent&lt;birdController&gt;().orderInList = numberSkullOnScreen;
  
              //add skull to list when turned on THIS WORKS YAY
              birdsOnScreen.Add(allSkulls[mySkull]);
              //Run function to place skulls
              placementSkulls();
          }
  
          else{
              allSkulls[mySkull].SetActive(false);
              skullOn[mySkull] = false;
              numberSkullOnScreen--;
  
              //remove skull from list when turned off-- THIS DOESNT WORK... 
              birdsOnScreen.RemoveAt(allSkulls[mySkull].gameObject.GetComponent&lt;birdController&gt;().orderInList);
  
  
              //Run function to place skulls based on the int number skulls on screen
              placementSkulls();
          }
      }
  </code></pre>