This question was
closed Feb 14, 2019 at 02:19 PM by
Brian-Santos for the following reason:
The question is answered, right answer was accepted
Question by
Brian-Santos · Feb 14, 2019 at 03:47 AM ·
wwwwebrequest
How to replace WWW() with UnityWebRequest
I'm a complete beginner in this area, may someone help me? I currently have:
string s;
...
StartCoroutine(OutputRoutine(new System.Uri(paths[0]).AbsoluteUri));
...
private IEnumerator OutputRoutine (string url){
var output = new WWW(url);
yield return output;
s = output.text;
}
But that gives me a warning:
warning CS0618: UnityEngine.WWW' is obsolete:
Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features'
How I can do what the warning says without changing the way it currently works? I don't want to change anything, just update the code to be more efficient and stop giving me warnings
Additional context, if needed: this code is from an example from SFB, which I'm using to save/load text files.
Comment
Best Answer
Answer by Brian-Santos · Feb 14, 2019 at 02:19 PM
Solved:
string s;
...
StartCoroutine(OutputRoutine(new System.Uri(paths[0]).AbsoluteUri));
...
private IEnumerator OutputRoutine (string url) {
var loaded = new UnityWebRequest(url);
loaded.downloadHandler = new DownloadHandlerBuffer();
yield return loaded.SendWebRequest();
s = loaded.downloadHandler.text;
}