1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class WebBundleRequest : BundleRequest
- {
- private UnityWebRequest _request;
- public bool cache;
- public Hash128 hash;
- public override float progress
- {
- get
- {
- if (isDone) return 1;
- if (LoadState == AssetLoadState.Init) return 0;
- if (_request == null) return 1;
- return _request.downloadProgress;
- }
- }
- internal override void Load()
- {
- _request = cache ? UnityWebRequestAssetBundle.GetAssetBundle(name, hash)
- : UnityWebRequestAssetBundle.GetAssetBundle(name);
- _request.SendWebRequest();
- LoadState = AssetLoadState.LoadAssetBundle;
- }
- internal override void Unload()
- {
- if (_request != null)
- {
- _request.Dispose();
- _request = null;
- }
- LoadState = AssetLoadState.Unload;
- base.Unload();
- }
- }
|