using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class WebGet : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
StartCoroutine(GetText());
}
// Update is called once per frame
void Update()
{
StartCoroutine(GetText());
}
IEnumerator GetText()
{
UnityWebRequest www = UnityWebRequest.Get("http://localhost:8080/proj/NetData");
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
// get data as a text.
Debug.Log(www.downloadHandler.text);
// get as a binary data.
//byte[] results = www.downloadHandler.data;
}
}
}
|