Created
December 29, 2017 09:46
-
-
Save yosun/52aa9a5e812c429bbbad4dde776f814a to your computer and use it in GitHub Desktop.
WWWPost using UnityEngine.Networking UnityWebRequest.Post
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 System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Networking; | |
public class WWWPost : MonoBehaviour { | |
public void Post(string url,WWWForm form){ | |
StartCoroutine(PostCoroutine(url,form)); | |
} | |
IEnumerator PostCoroutine(string url,WWWForm form) | |
{ | |
UnityWebRequest www = UnityWebRequest.Post(url, form); | |
www.chunkedTransfer = false; | |
yield return www.SendWebRequest(); | |
if (www.isNetworkError || www.isHttpError) | |
{ | |
Debug.Log(www.error); | |
} | |
else | |
{ | |
print(www.downloadHandler.text); | |
Debug.Log("Form upload complete!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment