반응형
1 using UnityEngine; 2 using System.Collections; 3 using System.Collections.Generic; 4 using System.Text; 5 using System.IO; 6 using System.Net; 7 8 public class WWWWiki : MonoBehaviour 9 10 { 11 // Use this for initialization 12 void Start() 13 { 14 15 } 16 17 // Update is called once per frame 18 19 void Update() 20 { 21 22 } 23 24 void OnGUI() 25 { 26 27 } 28 29 public WWW GET(string url) 30 { 31 WWW www = new WWW(url); 32 StartCoroutine(WaitForRequest(www)); 33 return www; 34 } 35 36 public WWW POST(string url, Dictionary<string, string> post) 37 { 38 39 WWWForm form = new WWWForm(); 40 41 foreach (KeyValuePair<string, string> post_arg in post) 42 { 43 44 form.AddField(post_arg.Key, post_arg.Value); 45 46 } 47 48 WWW www = new WWW(url, form); 49 StartCoroutine(WaitForRequest(www)); 50 return www; 51 52 } 53 54 55 private IEnumerator WaitForRequest(WWW www) 56 { 57 yield return www; 58 // check for errors 59 if (www.error == null) 60 { 61 Debug.Log("WWW Ok!: " + www.text); 62 } 63 else 64 { 65 Debug.Log("WWW Error: " + www.error); 66 } 67 } 68 69 }
Stack Over flow 에서 주섰습니다 ^ㅡ^
반응형
'Unity3D' 카테고리의 다른 글
[Unity3D][C#] 유니티에서 WWW From을 이용해 Cookie 리턴하기 (0) | 2013.07.30 |
---|