diff options
Diffstat (limited to 'Assets/Scripts/Managers/ResourceManager.cs')
-rw-r--r-- | Assets/Scripts/Managers/ResourceManager.cs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/Assets/Scripts/Managers/ResourceManager.cs b/Assets/Scripts/Managers/ResourceManager.cs index 858ad345..c0a4275d 100644 --- a/Assets/Scripts/Managers/ResourceManager.cs +++ b/Assets/Scripts/Managers/ResourceManager.cs @@ -1,18 +1,28 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+#if UNITY_EDITOR
+using UnityEditor;
+#endif
-public class ResourceManager : MonoBehaviour
+public class ResourceManager : Singleton<ResourceManager>
{
- // Start is called before the first frame update
- void Start()
- {
-
- }
+ Dictionary<string, Object> m_CachedObject = new Dictionary<string, Object>();
+
- // Update is called once per frame
- void Update()
+ public T LoadAsset<T>(string path) where T : UnityEngine.Object
{
-
+ if(m_CachedObject.ContainsKey(path))
+ {
+ return m_CachedObject[path] as T;
+ }
+
+#if UNITY_EDITOR
+ T obj = AssetDatabase.LoadAssetAtPath<T>(path);
+ m_CachedObject.Add(path, obj);
+#else
+#endif
+ return obj;
}
+
}
|