Created
December 31, 2015 22:57
-
-
Save emoacht/89590d4e4571d40f9e1b to your computer and use it in GitHub Desktop.
Sample usage of UnityWebRequest
This file contains 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
using System.Collections; | |
using UnityEngine; | |
using UnityEngine.Experimental.Networking; | |
public class UnityWebRequestUsage : MonoBehaviour | |
{ | |
void Start() | |
{ | |
StartCoroutine(GetText()); | |
} | |
IEnumerator GetText() | |
{ | |
using (UnityWebRequest request = UnityWebRequest.Get("http://unity3d.com/")) | |
{ | |
yield return request.Send(); | |
if (request.isError) // Error | |
{ | |
Debug.Log(request.error); | |
} | |
else // Success | |
{ | |
Debug.Log(request.downloadHandler.text); | |
} | |
} | |
} | |
} |
Hi, i need to assign this script to a GAMEOBJECT?
I need receive a text from a server.
Yes, Monobehaviours only function when assigned to a GameObject. So you can run a Coroutine only when on a GameObject.
Any sample usage about HTTPS / certificates ? (using auto-signed certificates ?)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i need to assign this script to a GAMEOBJECT?
I need receive a text from a server.