C# IEnumerator 搜索
yield return
//测试GET方法
StartCoroutine(SendGet("http://postman-echo.com/time/now"));
StartCoroutine(SendGet("http://postman-echo.com/time/now"));
//测试POST方法
var form = new WWWForm();
form.AddField("int", "6");
StartCoroutine(SendPost("http://kun.show.ghostry.cn/", form));
var form = new WWWForm();
form.AddField("int", "6");
StartCoroutine(SendPost("http://kun.show.ghostry.cn/", form));
IEnumerator SendGet(string _url)
{
WWW getData = new WWW(_url);
yield return getData;
if(getData.error != null)
{
Debug.Log(getData.error);
}
else
{
Debug.Log(getData.text);
}
}
{
WWW getData = new WWW(_url);
yield return getData;
if(getData.error != null)
{
Debug.Log(getData.error);
}
else
{
Debug.Log(getData.text);
}
}
IEnumerator SendPost(string _url, WWWForm _wForm)
{
WWW postData = new WWW(_url, _wForm);
yield return postData;
if (postData.error != null)
{
Debug.Log(postData.error);
}
else
{
Debug.Log(postData.text);
}
}
{
WWW postData = new WWW(_url, _wForm);
yield return postData;
if (postData.error != null)
{
Debug.Log(postData.error);
}
else
{
Debug.Log(postData.text);
}
}