unity load sprite from atlas code example

Example 1: load an image sprite script unity

void Start()
    {
        spriteArray = Resources.LoadAll<Sprite>("BirdHeroSprite");
    }

Example 2: load array with sprites unity

void Start(){      LoadIcons();     }      public Sprite[] Icons; // icons array             void LoadIcons(){                 object[] loadedIcons = Resources.LoadAll ("Icons",typeof(Sprite)) ;                 Icons = new Sprite[loadedIcons.Length];                //this                 for(int x = 0; x< loadedIcons.Length;x++){                     Icons [x] = (Sprite)loadedIcons [x];                 }               //or this               //loadedIcons.CopyTo (Icons,0);                  }

Tags:

Misc Example