Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ResourceCache< T > Class Template Reference

Public Member Functions

 ResourceCache (string _path="")
 
void Clear ()
 
Get (string id, ResourceLoadType loadType=ResourceLoadType.Resource, object option=null)
 
T2 Get< T2 > (string id, ResourceLoadType loadType=ResourceLoadType.Resource)
 

Static Public Member Functions

static T Load< T > (string path)
 
static T LoadBundle< T > (string path)
 

Public Attributes

Dictionary< string, T > dict = new Dictionary<string, T>()
 
string path
 

Static Public Attributes

static ResourceCache< Object > caches = new ResourceCache<Object>()
 

Detailed Description

Type Constraints
T :Object 

Definition at line 19 of file ResourceCache.cs.

Constructor & Destructor Documentation

◆ ResourceCache()

ResourceCache< T >.ResourceCache ( string  _path = "")
inline

Definition at line 25 of file ResourceCache.cs.

26 {
27 path = _path;
28 }

References ResourceCache< T >.path.

Member Function Documentation

◆ Clear()

void ResourceCache< T >.Clear ( )
inline

Definition at line 30 of file ResourceCache.cs.

31 {
32 foreach (T value in dict.Values)
33 {
34 Object.DestroyImmediate(value);
35 }
36 dict.Clear();
37 }
Dictionary< string, T > dict

References ResourceCache< T >.dict.

◆ Get()

T ResourceCache< T >.Get ( string  id,
ResourceLoadType  loadType = ResourceLoadType::Resource,
object  option = null 
)
inline

Definition at line 39 of file ResourceCache.cs.

40 {
41 T value = null;
42 string key = typeof(T).Name + id;
43 if (!dict.TryGetValue(key, out value))
44 {
45 value = ((loadType == ResourceLoadType.Streaming) ? IO.LoadObject<T>(path + id, option) : Resources.Load<T>(path + id));
46 dict.Add(key, value);
47 }
48 return value;
49 }
ResourceLoadType
Definition: IO.cs:11

References ResourceCache< T >.dict, and ResourceCache< T >.path.

Referenced by ResourceCache< T >.Load< T >(), and ResourceCache< T >.LoadBundle< T >().

◆ Get< T2 >()

T2 ResourceCache< T >.Get< T2 > ( string  id,
ResourceLoadType  loadType = ResourceLoadType::Resource 
)
inline
Type Constraints
T2 :Object 

Definition at line 51 of file ResourceCache.cs.

51 : Object
52 {
53 T value = null;
54 string key = typeof(T2).Name + id;
55 if (!dict.TryGetValue(key, out value))
56 {
57 T2 val = null;
58 val = ((loadType != 0) ? AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/Bundle/" + id).LoadAsset<GameObject>(new FileInfo(id).Name).GetComponent<T2>() : Resources.Load<T2>(path + id));
59 dict.Add(key, val as T);
60 return val;
61 }
62 return value as T2;
63 }

References AssetBundle, ResourceCache< T >.dict, and ResourceCache< T >.path.

◆ Load< T >()

static T ResourceCache< T >.Load< T > ( string  path)
inlinestatic
Type Constraints
T :Object 

Definition at line 9 of file ResourceCache.cs.

9 : Object
10 {
11 return caches.Get<T>(path);
12 }
static ResourceCache< Object > caches
Definition: ResourceCache.cs:7
T Get(string id, ResourceLoadType loadType=ResourceLoadType.Resource, object option=null)

References ResourceCache< T >.caches, ResourceCache< T >.Get(), and ResourceCache< T >.path.

◆ LoadBundle< T >()

static T ResourceCache< T >.LoadBundle< T > ( string  path)
inlinestatic
Type Constraints
T :Object 

Definition at line 14 of file ResourceCache.cs.

14 : Object
15 {
16 return caches.Get<T>(path, ResourceLoadType.AssetBundle);
17 }

References ResourceCache< T >.caches, ResourceCache< T >.Get(), and ResourceCache< T >.path.

Member Data Documentation

◆ caches

ResourceCache<Object> ResourceCache< T >.caches = new ResourceCache<Object>()
static

◆ dict

Dictionary<string, T> ResourceCache< T >.dict = new Dictionary<string, T>()

◆ path


The documentation for this class was generated from the following file: