using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; namespace Passer { public class CoreUpdater : MonoBehaviour { private void Awake() { #if UNITY_EDITOR StartCoroutine(GetCore("http://passervr.com/testsites/PasserCore.dll")); #endif } IEnumerator GetCore(string uri) { using (UnityWebRequest webRequest = UnityWebRequest.Get(uri)) { // Request and wait for the desired page. yield return webRequest.SendWebRequest(); string[] pages = uri.Split('/'); int page = pages.Length - 1; #if UNITY_2021_2_OR_NEWER if (webRequest.result == UnityWebRequest.Result.ConnectionError) #else if (webRequest.isNetworkError) #endif { Debug.Log(pages[page] + ": Error: " + webRequest.error); yield return null; } if (webRequest.downloadHandler.isDone == false) { Debug.Log("partial download"); yield return null; } DownloadHandler x = webRequest.downloadHandler; string savePath = string.Format("{0}/Passer/Plugins/PasserCore.dll", Application.dataPath); Debug.Log(savePath); System.IO.File.WriteAllBytes(savePath, webRequest.downloadHandler.data); Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text); } } } }