コード例 #1
0
        public void OpenAsync(OnAssetBundleLoadedCallback onLoadedCallback, OnErrorCallback onErrorCallback)
        {
            if (string.IsNullOrEmpty(mName) || mIsOpened || mCoroutineContext == null)
            {
                throw new InvalidOperationException();
            }

            mCoroutineContext.ExecuteCoroutine(_openAsync(mName, onLoadedCallback, onErrorCallback));
        }
コード例 #2
0
        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);
        }