title: How To give Unique Id's To Instantiated Objects In Unity C#
body: <p>I was looking around for quite some time to find the best way to give instantiated objects unique id's in Unity. I found tons of ways but none worked for the game I am making.
  I figured out my own way to do this and thought I would share!</p>
  
  <p>This is for my UI at main menu. I am instantiating buttons based on how many sprites I have in my resources folder. I needed each button to change the player skin to a different sprite so they needed unique ids.</p>
  
  <p>Attached this script to my button prefab:</p>
  
  <pre><code>    public class ShopButtons : MonoBehaviour
  {
      public static int[] buttonArray = new int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
      public static int arIndex = 0;
  
      public int buttonID;
  
  
      void Start()
          {
              if (buttonArray[arIndex] == 0)
              {
                  buttonID = arIndex;
                  buttonArray[arIndex] = 1;
              }
               arIndex++;
           }
  }
  </code></pre>
  
  <p>I am a beginner so tips are appreciated. This is my first time using arrays and it worked wonders for my project!</p>