//异步加载 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; } } }
//异步加载图集 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); }
//加入缓冲区 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(); } } }
//同步加载 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); } }