public void OpenAsync(OnAssetBundleLoadedCallback onLoadedCallback, OnErrorCallback onErrorCallback) { if (string.IsNullOrEmpty(mName) || mIsOpened || mCoroutineContext == null) { throw new InvalidOperationException(); } mCoroutineContext.ExecuteCoroutine(_openAsync(mName, onLoadedCallback, onErrorCallback)); }
protected IEnumerator _openAsync(string filename, OnAssetBundleLoadedCallback successCallback = null, OnErrorCallback errorCallback = null) { UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(filename); yield return(www.SendWebRequest()); if (www.isNetworkError) { errorCallback?.Invoke(www.error); yield break; } mAssetBundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle; mIsOpened = true; successCallback?.Invoke(this); yield return(null); }