Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- public class SpriteManager : MonoBehaviour {
- public static Dictionary<string, Sprite[]> sprites = new Dictionary<string, Sprite[]>();
- // Use this for initialization
- void Awake () {
- SpriteManager.LoadSprites();
- }
- public static void LoadSprites(){
- DirectoryInfo dir = new DirectoryInfo("Assets/Resources/Textures");
- FileInfo[] info = dir.GetFiles("*.*");
- foreach (FileInfo f in info) {
- string name = f.Name.Split('.')[0];
- if( !sprites.ContainsKey( name ) ){
- sprites.Add( name, Resources.LoadAll<Sprite>("Textures/" + name) );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement