AIプログラムとかUnityゲーム開発について

探索や学習などを活用したAI系ゲームを作りたいと思います。

VPSレンタル #3

以下のコードでHTTPのGETできた。以前はcrossdomainのxmlを置かないと動かなった記憶があるけど、置かないでも動いた。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class http : MonoBehaviour {
	void Start () {
        StartCoroutine(HttpGet("http:// CGIのアドレス ?a=get&k=key1"));
    }

	void Update () {
	}
    IEnumerator HttpGet(string url)
    {
        WWW www = new WWW(url);
        yield return StartCoroutine(CheckTimeOut(www, 5f));
        if (www.error == null)
            Debug.Log(www.text);
        else
            Debug.Log(www.error);
    }
    IEnumerator CheckTimeOut(WWW www, float timeout)
    {
        float requestTime = Time.time;

        while (!www.isDone)
        {
            if (Time.time - requestTime < timeout)
                yield return null;
            else
            {
                Debug.Log("TimeOut");
                break;
            }
        }
        yield return null;
    }
}


mariadbを入れたので、phpMyAdminを入れてみる。
以下を参考にする。
qiita.com

無事動きました。
f:id:yasu9780:20170103210806p:plain