示例#1
0
            private IEnumerator GetAssetBundle(string url, Hash128 hash)
            {
                DebugConditional.LogFormat("-- load bundle from {0}...", url);
                var www = UnityWebRequestAssetBundle.GetAssetBundle(url, hash);

                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    throw new Exception($"Failed to load bundle {url} with error: {www.error}");
                }

                _loadRoutine = null;

                Bundle = DownloadHandlerAssetBundle.GetContent(www);

                if (_isDisposed)
                {
                    Bundle.Unload(true);
                    Bundle = null;
                }
                else
                {
                    ManageAtlases();
                    ManageSounds();
                    DebugConditional.Log("... bundle loaded successfully.");
                    _complete.SetValueAndForceNotify(true);
                }
            }
示例#2
0
        private IEnumerator LoadManifest(string path)
        {
            DebugConditional.LogFormat("-- load bundles manifest from {0}...", path);
            using (var www = UnityWebRequest.Get(path))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.LogErrorFormat("Failed to load manifest from {0} with error: {1}", path, www.error);
                }
                else
                {
                    var manifest = JsonUtility.FromJson <BundleManifest>(www.downloadHandler.text);
                    _bundleDataMap = manifest.Bundles.ToDictionary(description => description.Name);
                    DebugConditional.Log("... manifest loaded successfully.");
                    _ready.SetValueAndForceNotify(true);
                }
            }
        }