summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Managers/ResourceManager.cs
blob: c0a4275d2667eb3ca67dcd0adad49fcee2944cd1 (plain)
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

public class ResourceManager : Singleton<ResourceManager>
{
    Dictionary<string, Object> m_CachedObject = new Dictionary<string, Object>();


    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;
    }

}