당신은 데이터 (C 번호 + 유니티)의 세 가지 10 개의 타워 기능을 보내기/받기 달성 할 수있는 좋은 것받을 수 있습니다. POST 요청에 대한
using UnityEngine;
public class GetRequestDEmo : MonoBehaviour {
void Start() {
string url = "http://exampleWeb.com/myServerScript.php?var1=value2&var2=value2";
WWW www = new WWW(url);
StartCoroutine(WaitForRequest(www));
}
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// check for errors
if (www.error == null)
{
Debug.Log("WWW Result!: " + www.text);// contains all the data sent from the server
} else {
Debug.Log("WWW Error: "+ www.error);
}
}
}
: GET 요청 들어
: 모두가 아래에 주어진 데모에서는 WWWForm
의 Co-routine, WWW,
public class PostRequestDemo : MonoBehaviour {
void Start() {
string url = "http://exampleWeb.com/myServerscript.php";
WWWForm form = new WWWForm();
form.AddField("var1", "value1");
form.AddField("var2", "value2");
WWW www = new WWW(url, form);
StartCoroutine(WaitForRequest(www));
}
IEnumerator WaitForRequest(WWW www)
{
yield return www
// check for errors
if (www.error == null)
{
Debug.Log("WWW Ok!: " + www.text);// contains all the data sent from the server
} else {
Debug.Log("WWW Error: "+ www.error);
}
}
}
당신의 원하는 경우 에버 사이드 코드 (PHP에서) 또한, 나는 당신을 추천 할 것입니다 his Unity Wiki code. 또는 수도 있습니다 this Video.
http://answers.unity3d.com/questions/11021/how-can-i-send-and-receive-data-to-and-from-a-url.html –
HTTP : //stackoverflow.com/questions/8951489/unity-get-post-wrapper –
@ Umair M 많은 감사합니다 더 자세한 버전이 있습니까? –