Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
SpriteSheet.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class SpriteSheet : MonoBehaviour
5{
6 public static Dictionary<string, Sprite> dict = new Dictionary<string, Sprite>();
7
8 public static HashSet<string> loadedPath = new HashSet<string>();
9
10 public static void Add(Sprite sprite)
11 {
12 dict[sprite.name] = sprite;
13 }
14
15 public static void Add(string path)
16 {
17 if (!loadedPath.Contains(path))
18 {
19 Sprite[] array = Resources.LoadAll<Sprite>(path);
20 foreach (Sprite sprite in array)
21 {
22 dict[sprite.name] = sprite;
23 }
24 loadedPath.Add(path);
25 }
26 }
27
28 public static Sprite Get(string id)
29 {
30 return dict.TryGetValue(id);
31 }
32
33 public static Sprite Get(string path, string id)
34 {
35 if (!loadedPath.Contains(path))
36 {
37 Add(path);
38 }
39 dict.TryGetValue(id, out var value);
40 return value;
41 }
42}
static void Add(Sprite sprite)
Definition: SpriteSheet.cs:10
static void Add(string path)
Definition: SpriteSheet.cs:15
static Sprite Get(string id)
Definition: SpriteSheet.cs:28
static Sprite Get(string path, string id)
Definition: SpriteSheet.cs:33
static Dictionary< string, Sprite > dict
Definition: SpriteSheet.cs:6
static HashSet< string > loadedPath
Definition: SpriteSheet.cs:8