// open file stream (file must be listed in manifest) private void OpenBundle(UBundle bundle) { var filename = bundle.name; if (LoadBundleFile(bundle, _localPathRoot)) { return; } if (_streamingAssets != null && _streamingAssets.Contains(bundle.name, bundle.checksum, bundle.size)) { bundle.AddRef(); JobScheduler.DispatchCoroutine( _streamingAssets.LoadBundle(bundle.name, stream => { if (stream != null) { bundle.Load(stream); } else { PrintLog($"read from streamingassets failed: {bundle.name}"); DownloadBundleFile(bundle); } bundle.RemoveRef(); }) ); return; } DownloadBundleFile(bundle); }
private void OnAssetCompleted(UAsset asset) { if (_state == SceneState.Loading && asset.isLoaded) { JobScheduler.DispatchCoroutine(_LoadAsync()); } }
public void Close() { if (!_closed) { _closed = true; JobScheduler.DispatchCoroutine(_OnClosing()); } }
protected void _LoadAsset(IEnumerator e) { if (_closed) { return; } _assetLoaders.AddLast(e); if (_assetLoaders.Count == 1) { JobScheduler.DispatchCoroutine(_AssetLoader()); } }
protected void _LoadBundle(IEnumerator e) { if (_closed) { return; } _bundleLoaders.AddLast(e); if (_bundleLoaders.Count == 1) { JobScheduler.DispatchCoroutine(_BundleLoader()); } }
// 下载包文件 (优先考虑从 StreamingAssets 载入, 无法载入时从网络下载) //NOTE: 调用此接口时已经确认本地包文件无效 (本地临时存储) private void DownloadBundleFile(Manifest.BundleInfo bundleInfo, Action callback) { var oldJob = _FindDownloadJob(bundleInfo.name); if (oldJob != null) { if (callback != null) { oldJob.callback += callback; } return; } if (_streamingAssets.Contains(bundleInfo)) { JobScheduler.DispatchCoroutine( _streamingAssets.LoadStream(bundleInfo, stream => { if (stream != null) { var bundle = TryGetBundle(bundleInfo); if (bundle != null) { bundle.Load(Utils.Helpers.GetDecryptStream(stream, bundle.bundleInfo, _password, _manifestObject.chunkSize)); } else { stream.Close(); } callback?.Invoke(); } else { Debug.LogWarningFormat("read from streamingassets failed: {0}", bundleInfo.name); _DownloadBundleFile(bundleInfo, callback, true); } }) ); } else { _DownloadBundleFile(bundleInfo, callback, true); } }
public void UnloadScene() { if (_state != SceneState.Ready) { if (_state == SceneState.Loaded) { _state = SceneState.Unloading; JobScheduler.DispatchCoroutine(_UnloadAsync()); } else { if (_asset.isLoaded) { _state = SceneState.Unloading; } else { _state = SceneState.Ready; } } } }
public void OpenManifest(Action <StreamingAssetsLoader> callback) { JobScheduler.DispatchCoroutine(OpenManifestCo(callback)); }