A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.unity3d.com/6000.0/Documentation/Manual/web-request-retrieving-text-binary-data.html below:

Manual: Retrieving text or binary data from an HTTP Server (GET)

Common operations: using the HLAPI

Retrieving a Texture from an HTTP Server (GET)

Retrieving text or binary data from an HTTP Server (GET)

To retrieve simple data such as textual data or binary data from a standard HTTP or HTTPS web server, use the UnityWebRequest.GET call. This function takes a single string as an argument, with the string specifying the URL from which data is retrieved.

This function is analogous to the standard WWW constructor:

WWW myWww = new WWW("https://www.myserver.com/foo.txt");
// ... is analogous to ...
UnityWebRequest myWr = UnityWebRequest.Get("https://www.myserver.com/foo.txt");
Details Example
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
 
public class MyBehaviour : MonoBehaviour {
    void Start() {
        StartCoroutine(GetText());
    }
 
    IEnumerator GetText() {
        UnityWebRequest www = UnityWebRequest.Get("https://www.my-server.com");
        yield return www.SendWebRequest();
 
        if (www.result != UnityWebRequest.Result.Success) {
            Debug.Log(www.error);
        }
        else {
            // Show results as text
            Debug.Log(www.downloadHandler.text);
 
            // Or retrieve results as binary data
            byte[] results = www.downloadHandler.data;
        }
    }
}

Common operations: using the HLAPI

Retrieving a Texture from an HTTP Server (GET)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4