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

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

}