title: how to create an enum for a prefab to be instantiated with an image for sprite
body: <p>Basically I’ve created a prefab, “badGuy” of which there are three types. Each has it’s their own sprite images. So I created the following enum in a script attached to my badGuy prefab:</p>
  
  <pre><code>public enum BadGuyType {
    green,
    blue,
    red
  }
  </code></pre>
  
  <p>All along I have been using one image for my prefab since I didn’t have a enum. The badGuy game object had a public property for  me to add it through the inspector and instantiate it a number of times as below:</p>
  
  <pre><code>public GameObject badGuy; //I set this in the inspector
  void Start () {
  
  badGuys= new List&lt;GameObject&gt; ();
  
  int numberOfBadGuys = 6;
  Camera camera = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent&lt;Camera&gt; ();
  
  for (int i = 1; i &lt; numberOfBadGuys + 1; i++) {
      GameObject badGuyObject =  (GameObject)Instantiate(badGuy, new Vector3(Screen.width*i/2, Screen.height*i/6, camera.nearClipPlane ), Quaternion.identity );
      badGuys.Add(badGuyObject);
  }
  </code></pre>
  
  <p>How can I set images (preferably programmatically) for my BadGuyType enum and select them when instantiating my badGuy game objects?</p>