13
\$\begingroup\$

Unity 4.3 newly brings an ability to cut up a sprite sheet into multiple individual sprites. This is useful since you then only need one master spritesheet, but nevertheless get references to individual sprites. It's done by setting Sprite Mode to Multiple.

Can all the sprites generated from the master file be programmatically accessed from the Unity Sprite Editor?

For example: I have a spritesheet with a grid of 50x50 sprites. Using the Unity Sprite Editor, I now have 250 sprites: spritesheet_0, spritesheet_1, ..., spritesheet_249. How can I get a handle to spritesheet_102 without having to manually drag and drop it in the Unity editor?

\$\endgroup\$

1 Answer 1

6
\$\begingroup\$

You need to create a sprite array Sprite[] sprites and fill it using sprites = Resources.LoadAll<Sprite>("Location"); inside Awake().

\$\endgroup\$
1
  • \$\begingroup\$ Also make sure all sprites are in Resources folder to use Resources.LoadAll(). \$\endgroup\$ Jun 1, 2015 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .