private IEnumerator LoadCo(string path, LoadAssetIndexForInstallerCallbackSet callbackSet, object context) { if (Application.platform != RuntimePlatform.Android) { path = "file://" + path; } var www = UnityWebRequest.Get(path); yield return(www.SendWebRequest()); if (!string.IsNullOrEmpty(www.error)) { callbackSet.OnFailure?.Invoke(context); } else { if (callbackSet.OnSuccess != null) { using (var stream = new MemoryStream(www.downloadHandler.data)) { callbackSet.OnSuccess(stream, context); } } } }
public void Load(string path, LoadAssetIndexForInstallerCallbackSet callbackSet, object context) { if (m_MonoBehaviour == null || !m_MonoBehaviour.isActiveAndEnabled) { throw new InvalidOperationException("Behaviour is not ready to use."); } m_MonoBehaviour.StartCoroutine(LoadCo(path, callbackSet, context)); }