title: How can I enable one by one an array element(C#) Unity
body: <p>This code is C# and I'm using the Unity game engine.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  
  public class CollisionDetectionForQuest : MonoBehaviour {
  
  public GameObject[] Garbages;
  public GameObject[] GarbagesDummy;
  public bool activateInactive;
  //public GameObject[] Counter;
  
  
  void Start(){
  
      Garbages = GameObject.FindGameObjectsWithTag("Trash");
      foreach (GameObject garb in Garbages) {
  
      }
  
      GarbagesDummy = GameObject.FindGameObjectsWithTag ("TrashDummy");
      foreach(GameObject dummy in GarbagesDummy){
          dummy.gameObject.SetActive (false); 
      }
  }
  
  void OnCollisionEnter(Collision obj){
      if (obj.gameObject.CompareTag ("Trash")) {
          obj.gameObject.SetActive (false);
          activateInactive = true;
  
         //in this line i want to activate my GarbageDummy 1 by 1 base on
         //every Trash i put in my collider.
          foreach(GameObject a in GarbagesDummy){
              a.gameObject.SetActive (true);
          }
  }
  </code></pre>
  
  <p>So basically I want to activate the <strong>garbagedummy</strong> gameobject 1 by 1 on every <strong>trash</strong> I put on my collider. But I tried this and it doesn't work:</p>
  
  <pre><code>foreach(GameObject dummy in GarbageDummy){
     for(int i = 0; i &lt; GarbageDummy.Length; i++){
       dummy.gameobject.setActive(true);
    }
  }
  </code></pre>
  
  <p>anyone help please.</p>
  
  <p>Here is my screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/USf1I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/USf1I.png" alt="Here"></a></p>