コード例 #1
0
ファイル: ResLoader.cs プロジェクト: nmbswls/CSCI529
    public T LoadResource <T>(string path, bool cached = true) where T : UnityEngine.Object
    {
        T ret = null;

        if (!string.IsNullOrEmpty(path))
        {
            ret = mGOPool.GetPoolPrefab(path) as T;
            if (ret == null)
            {
                ret = mAssetPool.Get <T>(path);
            }

            if (ret == null)
            {
                ret = _LoadResPrefab <T>(path);

                if (ret != null && cached)
                {
                    GameObject prefab = ret as GameObject;
                    if (prefab != null)
                    {
                        mGOPool.CachePoolPrefab(path, prefab, true);
                    }
                    else
                    {
                        mAssetPool.AddAsset(path, ret);
                    }
                }
            }
        }
        return(ret);
    }