処理内容
- ボタンを表示
- ボタンを押すと指定したSceneに遷移
- 裏で、指定したURLに接続
using UnityEngine;
using System.Collections;
public class Title : MonoBehaviour {
void OnGUI () {
if (GUI.Button(new Rect(Screen.width/2 -100 , 100, 200, 50), "GAME START"))
{
Application.LoadLevel("particles");
StartCoroutine("LoadData");
}
}
private IEnumerator LoadData() {
string url = "http://localhost:3000";
WWW hoge = new WWW(url);
while (!hoge.isDone) {
yield return null;
}
}
}
少しハマったところ
↑上記ソースコードの、
WWW hoge = new WWW(url);
の部分で当初、変数hogeの前の型宣言を書かずにビルドしたら、
hoge does not exist in the current context
と怒られた。