From 86ec4522be1d0b932006801c7bf2297adc9f0028 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 30 Aug 2021 21:11:54 +0800 Subject: *misc --- Assets/Scripts/Managers/ResourceManager.cs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'Assets/Scripts/Managers/ResourceManager.cs') 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 { - // Start is called before the first frame update - void Start() - { - - } + Dictionary m_CachedObject = new Dictionary(); + - // Update is called once per frame - void Update() + public T LoadAsset(string path) where T : UnityEngine.Object { - + if(m_CachedObject.ContainsKey(path)) + { + return m_CachedObject[path] as T; + } + +#if UNITY_EDITOR + T obj = AssetDatabase.LoadAssetAtPath(path); + m_CachedObject.Add(path, obj); +#else +#endif + return obj; } + } -- cgit v1.1-26-g67d0