public static void LoadSkybox(string _package, string _file , OnLoadReadyDelegate _onReady , OnLoadObjectSuccessDelegate _onSuccess , OnErrorDelegate _onError) { if (string.IsNullOrEmpty(_package)) { _onError("package is null"); return; } if (string.IsNullOrEmpty(_file)) { _onError("file is null"); return; } _onReady(); CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) => { Log.Debug("ResourceMgr", "load skybox [{0}] finish...", _file); CameraMgr.ApplySkybox(_res as Material); _onSuccess(_res); }, _onError)); }
public static void LoadAudioClip(string _package, string _file, int _track , OnLoadReadyDelegate _onReady , OnLoadObjectSuccessDelegate _onSuccess , OnErrorDelegate _onError) { if (string.IsNullOrEmpty(_package)) { _onError("package is null"); return; } if (string.IsNullOrEmpty(_file)) { _onError("file is null"); return; } _onReady(); CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) => { Log.Debug("ResourceMgr", "load audioclip [{0}] finish...", _file); _onSuccess(_res); }, _onError)); }
public static void PreloadAnyRes(string _package, string _file , OnLoadReadyDelegate _onReady , OnLoadObjectSuccessDelegate _onSuccess , OnErrorDelegate _onError) { if (string.IsNullOrEmpty(_package)) { _onError("package is null"); return; } if (string.IsNullOrEmpty(_file)) { _onError("file is null"); return; } _onReady(); }
public static void PreloadAsset(string _package, string _file , OnLoadReadyDelegate _onReady , OnLoadObjectSuccessDelegate _onSuccess , OnErrorDelegate _onError) { if (string.IsNullOrEmpty(_package)) { _onError("package is null"); return; } if (string.IsNullOrEmpty(_file)) { _onError("file is null"); return; } _onReady(); string assetID = _package + "@" + _file; if (!preloadAssets.ContainsKey(assetID)) { preloadAssets.Add(assetID, null); CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) => { Log.Debug("ResourceMgr", "load res [{0}] finish...", assetID); preloadAssets[assetID] = _res; _onSuccess(_res); }, _onError)); } else { Log.Debug("ResourceMgr", "res [{0}] is exists...", assetID); _onSuccess(preloadAssets[assetID]); } }
private static IEnumerator asyncLoadBundle(string _bundle, string _res, OnLoadObjectSuccessDelegate _onSuccess, OnErrorDelegate _onError) { AssetBundle bundle = null; if (bundles.ContainsKey(_bundle)) { bundle = bundles[_bundle]; } else { string path = Path.Combine(VRXX.Platform.GetStreamingAssetsPath() + "/pkgs/" + VRXX.Platform.Alias, _bundle); //string path = Path.Combine(VRXX.Platform.GetPersistentDataPath() + "/pkgs/" + VRXX.Platform.Alias, _bundle); Log.Debug("ResourceMgr", "load bundle from {0}", path); WWW www = new WWW(path); yield return(www); if (null != www.error) { _onError(www.error); yield break; } bundle = www.assetBundle; if (null == bundle) { _onError("bundle is null"); yield break; } bundles.Add(_bundle, bundle); } AssetBundleRequest req = bundle.LoadAssetAsync(_res); yield return(req); _onSuccess(req.asset); }