We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Under ScriptEngine's INTEROP section, make sure to set the Objects mapping for "uwr".
// Javascript var uwr = require("uwr") // This is the exposed UnityWebRequestUsage object uwr.GetTextFromUri("https://www.google.com", (text) => { log(text) })
// C# using System; using System.Collections; using UnityEngine; using UnityEngine.Networking; public class UnityWebRequestUsage : MonoBehaviour { public void GetTextFromUri(string uri, Action<string> callback) { StartCoroutine(GetText(uri, callback)); } IEnumerator GetText(string uri, Action<string> callback) { using (UnityWebRequest request = UnityWebRequest.Get(uri)) { yield return request.Send(); if (request.result == UnityWebRequest.Result.ConnectionError) { // Error callback(request.error); } else { // Success callback(request.downloadHandler.text); } } } }