private IEnumerator CacheInternal(string id, ResCategory cat, Action <string> OnCached, Action <string, string, string> OnError, CacheOption options, Type[] typeF, IAsyncProgress prog) { _inLoading.Add(id); WWW l = new WWW(ConvertToUrl(id)); prog.Next(l); yield return(l); if (l.error != null) { if (OnError != null) { OnError(id, l.url, l.error); } else { DefaultOnError(id, l.url, l.error); } } PostProcessByCategory(id, l, cat, typeF); if (options > CacheOption._Ignorable) { OptionalPostProcess(id, cat, options); } if (OnCached != null) { OnCached(id); } _inLoading.Remove(id); }
public IAsyncProgress Cache(string id, ResCategory cat, Action <string> OnCached, Action <string, string, string> OnError, params Type[] typeF) { if (_inLoading.Contains(id) || _pool.ContainsKey(id)) { return(null); } LoadProgress lp = new LoadProgress(); CrExe.StartCoroutine(CacheInternal(id, cat, OnCached, OnError, 0, typeF, lp)); return(lp); }
private void PostProcessByCategory(string id, WWW loader, ResCategory cat, Type[] typeF) { switch (cat) { case ResCategory.Audio: //TODO : loader.GetAudioClip(); break; case ResCategory.Binary: //TODO : loader.bytes break; case ResCategory.Text: //TODO : loader.text break; case ResCategory.Video: //TODO : loader.movie; break; case ResCategory.Character: { GameObject t = loader.assetBundle.mainAsset as GameObject; if (t == null) { Debug.LogError("assetbundle from (" + loader.url + ") does not contain the requested GameObject (id = " + id + ")"); } else { _pool.Add(id, t); } } break; case ResCategory.Scene: { AssetBundle ab = loader.assetBundle; //load the bundle into memory } break; case ResCategory.Shader: { Shader t = loader.assetBundle.mainAsset as Shader; if (t == null) { Debug.LogError("assetbundle from (" + loader.url + ") does not contain the requested Shader (id = " + id + ")"); } else { _pool.Add(id, t); } } break; } }
public ResCategory GetCategory(AuthenticationInfo objAuthInfo) { ResCategory objResponse = new ResCategory(); try { // entry log } catch (Exception ex) { objResponse.Result = CreateResult(ex, objAuthInfo); } finally { // exit log } return(objResponse); }
private void OptionalPostProcess(string id, ResCategory cat, CacheOption options) { //TODO }
public IAsyncProgress Cache <R> (string id, ResCategory cat, Action <string> OnCached) where R : UnityEngine.Object { return(Cache(id, cat, OnCached, null, typeof(R))); }
public IAsyncProgress Cache(string id, ResCategory cat, Action <string> OnCached) { return(Cache(id, cat, OnCached, null, null)); }