示例#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;
                }
            }
        }
示例#2
0
        //异步加载图集
        public Sprite LoadAssetAsyncSprite(string path, SpriteAtlas spratl, string strName)
        {
            CacheDataInfo info = queryCache(path);

            if (info != null)
            {
                info.UpdateTick();
                return(info.CacheObj as Sprite);
            }

            return(null);
        }
示例#3
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();
                }
            }
        }
示例#4
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);
            }
        }