private IEnumerator asyncLoadBundle(UniResOperation _op, string _bundle, OnLoadBundleFinishDelegate _finish) { string dir = Application.streamingAssetsPath; if (externalBundles.Contains(_bundle)) { dir = Application.persistentDataPath; } if (!dir.Contains("file://")) { dir = dir.Insert(0, "file://"); } string path = System.IO.Path.Combine(dir, "res/" + _bundle); WWW www = new WWW(path); _op.Use(www); yield return(www); if (null != www.error) { this.LogError(www.error); yield break; } AssetBundle bundle = www.assetBundle; if (null == bundle) { this.LogError("bundle is null"); yield break; } bundles.Add(_bundle, bundle); www.Dispose(); _op.Use(1.0f); _finish(bundle); }
private IEnumerator asyncLoadRes <T> (UniResOperation _op, AssetBundle _bundle, string _res, OnLoadResFinishDelegate <T> _finish) where T : Object { AssetBundleRequest req = _bundle.LoadAssetAsync <T> (_res); _op.Use(req); yield return(req); this.LogDebug("Load res {0} finish", _res); _op.Use(1.0f); _finish(req.asset as T); }
public IResOpeartion AsyncLoadRes <T> (string _bundle, string _res, OnLoadResFinishDelegate <T> _finish) where T : Object { this.LogDebug("Load res {0} from {1}... ", _res, _bundle); AssetBundle bundle = null; UniResOperation op = new UniResOperation(); if (bundles.TryGetValue(_bundle, out bundle)) { mono.StartCoroutine(asyncLoadRes <T> (op, bundle, _res, _finish)); } else { this.LogError("bundle {0} is not exists!", _bundle); op.Use(0.0f); } return(op); }
public IResOpeartion AsyncLoadBundle(string _bundle, OnLoadBundleFinishDelegate _finish) { UniResOperation op = new UniResOperation(); if (!bundles.ContainsKey(_bundle)) { this.LogDebug("Load Bundle {0} ... ", _bundle); mono.StartCoroutine(asyncLoadBundle(op, _bundle, (_ab) => { this.LogDebug("Load Bundle {0} finish", _bundle); _finish(_ab); })); } else { op.Use(1.0f); this.LogDebug("Load exits Bundle {0}", _bundle); _finish(bundles [_bundle]); } return(op); }