Created
March 25, 2019 09:50
-
-
Save suzumura-ss/0e21a44701d498d0d791b9fea134091b to your computer and use it in GitHub Desktop.
"`UnityEngine.WWW' is obsolete" に対するパッチ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Assets/SteamVR/Editor/SteamVR_Update.cs b/Assets/SteamVR/Editor/SteamVR_Update.cs | |
index 51e65cf..80abe40 100644 | |
--- a/Assets/SteamVR/Editor/SteamVR_Update.cs | |
+++ b/Assets/SteamVR/Editor/SteamVR_Update.cs | |
@@ -8,6 +8,7 @@ using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
using System.Text.RegularExpressions; | |
+using UnityEngine.Networking; | |
[InitializeOnLoad] | |
public class SteamVR_Update : EditorWindow | |
@@ -19,7 +20,7 @@ public class SteamVR_Update : EditorWindow | |
const string doNotShowKey = "SteamVR.DoNotShow.v{0}"; | |
static bool gotVersion = false; | |
- static WWW wwwVersion, wwwNotes; | |
+ static UnityWebRequest wwwVersion, wwwNotes; | |
static string version, notes; | |
static SteamVR_Update window; | |
@@ -33,13 +34,17 @@ public class SteamVR_Update : EditorWindow | |
if (!gotVersion) | |
{ | |
if (wwwVersion == null) | |
- wwwVersion = new WWW(versionUrl); | |
+ { | |
+ wwwVersion = UnityWebRequest.Get(versionUrl); | |
+ wwwVersion.downloadHandler = new DownloadHandlerBuffer(); | |
+ wwwVersion.SendWebRequest(); | |
+ } | |
if (!wwwVersion.isDone) | |
return; | |
if (UrlSuccess(wwwVersion)) | |
- version = wwwVersion.text; | |
+ version = wwwVersion.downloadHandler.text; | |
wwwVersion = null; | |
gotVersion = true; | |
@@ -47,7 +52,9 @@ public class SteamVR_Update : EditorWindow | |
if (ShouldDisplay()) | |
{ | |
var url = string.Format(notesUrl, version); | |
- wwwNotes = new WWW(url); | |
+ wwwNotes = UnityWebRequest.Get(url); | |
+ wwwNotes.downloadHandler = new DownloadHandlerBuffer(); | |
+ wwwNotes.SendWebRequest(); | |
window = GetWindow<SteamVR_Update>(true); | |
window.minSize = new Vector2(320, 440); | |
@@ -61,7 +68,7 @@ public class SteamVR_Update : EditorWindow | |
return; | |
if (UrlSuccess(wwwNotes)) | |
- notes = wwwNotes.text; | |
+ notes = wwwNotes.downloadHandler.text; | |
wwwNotes = null; | |
@@ -72,11 +79,11 @@ public class SteamVR_Update : EditorWindow | |
EditorApplication.update -= Update; | |
} | |
- static bool UrlSuccess(WWW www) | |
+ static bool UrlSuccess(UnityWebRequest req) | |
{ | |
- if (!string.IsNullOrEmpty(www.error)) | |
+ if (!string.IsNullOrEmpty(req.error)) | |
return false; | |
- if (Regex.IsMatch(www.text, "404 not found", RegexOptions.IgnoreCase)) | |
+ if (Regex.IsMatch(req.downloadHandler.text, "404 not found", RegexOptions.IgnoreCase)) | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment