Exemple #1
0
        //异步加载
        public void LoadAssetAsync <T>(string path, UnityAction <T> onLoadComplate) where T : Object
        {
            CacheDataInfo info = queryCache(path);

            if (info != null)
            {
                info.UpdateTick();
                if (onLoadComplate != null)
                {
                    onLoadComplate(info.CacheObj as T);
                }
            }
            else
            {
                switch (LoadMode)
                {
                case AssetLoadMode.Editor:
                    StartCoroutine(editorLoader.LoadAssetAsync <T>(path, onLoadComplate));
                    break;

                case AssetLoadMode.AssetBundler:
                    StartCoroutine(abLoader.LoadAssetAsync <T>(path, onLoadComplate));
                    break;
                }
            }
        }
Exemple #2
0
        //加入缓冲区
        public void pushCache(string path, Object obj)
        {
            Debug.Log("[AssetManager]加入缓存:" + path);

            lock (cacheDataDic) {
                if (cacheDataDic.ContainsKey(path))
                {
                    cacheDataDic[path].UpdateTick();
                }
                else
                {
                    CacheDataInfo info = new CacheDataInfo(path, obj);
                    cacheDataDic.Add(path, info);
                    info.UpdateTick();
                }
            }
        }
Exemple #3
0
        //同步加载
        public T LoadAsset <T>(string path) where T : Object
        {
            CacheDataInfo info = queryCache(path);

            if (info != null)
            {
                info.UpdateTick();
                return(info.CacheObj as T);
            }
            else
            {
                switch (LoadMode)
                {
                case AssetLoadMode.Editor:
                    return(editorLoader.LoadAsset <T>(path));

                case AssetLoadMode.AssetBundler:
                    return(abLoader.LoadAsset <T>(path));
                }
                return(null);
            }
        }