LoginSignup
0
0

More than 1 year has passed since last update.

unity5.2の作法 その23 www

Posted at

概要

unity5.2の作法、調べてみた。
wwwやってみた。

makefile

  • menu->file->new sceneする。
  • menu->file->save sceneでstartとする。
  • menu->gameobject->create emptyする。
  • menu->assetes->creates->c# scriptでstart.csつくる。
  • ダブルクリックして、コードを書く。
  • ヒエラルキーのgameobjectに、コードを重ねる。
  • 三角で実行。

サンプルコード

using UnityEngine;
using System.Collections;

public class www : MonoBehaviour {
    string json;
    void Start() {
        StartCoroutine("ReadMemo");
    }
    IEnumerator ReadMemo() {
        WWW www = new WWW("https://ohiapp0.herokuapp.com/hello");
        //WWW www = new WWW("http://carmania.dip.jp");
        yield return www;
        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(string.Format("Fail Whale!\n{0}", www.error));
            yield break;
        }
        json = www.text;
        Debug.Log(json);
    }
    void OnGUI() {
        GUI.color = Color.yellow;
        GUI.Label(new Rect(10, 10, 300, 300), json);
    }
}



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0