title: Creating a List of Unity Objects
body: <p>I'm trying to create a strip of sprites.  I created a list of game objects and it seems to work ok.  Except I have a duplicate object in the game view, so it seemed like I need to destroy my "template object".  When I do that it looks fine, but then when I try to move them it says I'm trying to access an object that has been destroyed.  Can someone help explain my issue?  It seems that I'm confused on Instantiate and how it works exactly.  I was under the impression that the object isn't created in the game view until the instantiate.  But then why do I get a duplicate object?  Thanks for your input.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  
  public class ReelStrip : MonoBehaviour {
      public List &lt;Sprite&gt; image = new List&lt;Sprite&gt;();
      public List &lt;int&gt; index = new List&lt;int&gt;();
      public List &lt;GameObject&gt; symbol = new List&lt;GameObject&gt; ();
      public int reelNumber;
      public float symbolHeight = 1.74f;
      public float symbolWidth = 2.00f;
      public float speed = 0.01f;
  
  
      // Use this for initialization
      void Start () {
          reelNumber = 0;
          loadStrip (new List&lt;int&gt;{0,0,1,2,4,1,4,5});
      }
  
      void addSymbol(int indexToAdd)
      { 
          string name = "reelNum: " + reelNumber + " index " + indexToAdd;
          SpriteRenderer renderer = new SpriteRenderer ();
          GameObject symbolObject = new GameObject (name);
          symbolObject.AddComponent&lt;SpriteRenderer&gt; ();
          renderer = symbolObject.GetComponent&lt;SpriteRenderer&gt; ();
          symbolObject.AddComponent&lt;symbol&gt; ();
          Sprite loadedSprite = Resources.Load &lt;Sprite&gt;(symbolNameAtIndex(indexToAdd)) as Sprite;
          renderer.sprite = loadedSprite;
          symbol.Add (symbolObject);
  
          Vector3 newPos;
          if(symbol.Count&lt;2)
          {
              newPos = new Vector3(0.0f,0.0f,0.0f);
                  }
                  else{
              newPos = new Vector3(symbol[symbol.Count-1].transform.position.x,symbol[symbol.Count-1].transform.position.y + symbolHeight, 0.0f);
              }
          Instantiate (symbol[symbol.Count-1], newPos, Quaternion.identity);
          // destroy template object
  
  
  ///// confused on the destroy //////
          //Destroy (symbolObject);
  
  
  
      }
  
      public void moveStripDown(float delta)
      {
          for (int i=0;i&lt;symbol.Count;i++)
          {
              symbol[i].transform.position = new Vector3(symbol[i].transform.position.x,symbol[i].transform.position.y - delta, symbol[i].transform.position.z);
  
          }
  
      }
  
      public void loadStrip(List &lt;int&gt; Indexes)
      {
          for (int i=0;i&lt;Indexes.Count;i++)
          {
              addSymbol (Indexes[i]);
          }
  
      }
  
      public string symbolNameAtIndex(int index)
      {
          string returnString;
      switch (index) {
          case 0:
              returnString = "img1";
              break;
          case 1:
              returnString = "img2";
              break;
          case 2:
              returnString = "img3";
              break;
          case 3:
              returnString = "img4";
              break;
          case 4:
              returnString = "img5";
              break;
          default:
              returnString = "symbolnotfound";
              break;
  
  
  
          }
  
          return returnString;
      }
  
      // Update is called once per frame
      void Update () {
  
          moveStripDown (speed*Time.deltaTime);
      }
  }
  </code></pre>