Advertisement
Guest User

SpriteManager

a guest
May 27th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5.  
  6. public class SpriteManager : MonoBehaviour {
  7. public static Dictionary<string, Sprite[]> sprites = new Dictionary<string, Sprite[]>();
  8. // Use this for initialization
  9. void Awake () {
  10. SpriteManager.LoadSprites();
  11. }
  12.  
  13. public static void LoadSprites(){
  14. DirectoryInfo dir = new DirectoryInfo("Assets/Resources/Textures");
  15. FileInfo[] info = dir.GetFiles("*.*");
  16. foreach (FileInfo f in info) {
  17. string name = f.Name.Split('.')[0];
  18. if( !sprites.ContainsKey( name ) ){
  19. sprites.Add( name, Resources.LoadAll<Sprite>("Textures/" + name) );
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement