-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathRuntimeScriptableObject.cs
More file actions
41 lines (37 loc) · 1.05 KB
/
Copy pathRuntimeScriptableObject.cs
File metadata and controls
41 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
#endif
using UnityEngine;
using System.Collections;
using System.IO;
public abstract class RuntimeScriptableObject<T> : ScriptableObject where T : ScriptableObject
{
// private static string[] guids;
// private static string path;
private static T cached;
private const string resourcesFolderName = "RSO";
public static T Get
{
get
{
if (cached != null)
{
//Debug.Log("[RSO] Get from cache.");
return cached;
}
T obj = (T)Resources.Load(resourcesFolderName + "/" + typeof(T).Name);
if (obj != null)
{
cached = obj;
}
else
{
cached = ScriptableObject.CreateInstance<T>();
//Debug.LogWarning("[RSO] Created new temporary data file at runtime! This is not permanent!");
}
//Debug.Log("[RSO] Get from resources.");
return cached;
}
}
}