Created
January 24, 2014 06:30
-
-
Save masayuki5160/8592951 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 UnityEngine; | |
using System.Collections; | |
public class testHttp : MonoBehaviour { | |
private string res; | |
IEnumerator download () { | |
string url = "http://www.unity3d.com/"; | |
WWW www = new WWW(url); | |
yield return www; | |
res = ""; | |
if (!string.IsNullOrEmpty(www.error) || string.IsNullOrEmpty(www.text)) { | |
// Http通信失敗 | |
res = "error"; | |
} else { | |
// コンテンツ取得したので中身を格納 | |
res = www.text; | |
} | |
} | |
void OnGUI () { | |
if (GUI.Button(new Rect(5, 5, 200, 20), "Test")) { | |
// ボタンが押されたらHttp通信開始 | |
StartCoroutine(download()); | |
} | |
GUI.Label(new Rect(5, 30, Screen.width, 200), res); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
【参考】http://d.hatena.ne.jp/nakamura001/20120825/1345858810
てかまんまやんw