Unity请求后台json数据

using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class RequestJosn : MonoBehaviour
{
   private string url = "http://xx.xx.xxx.xxx/gamedata";
    IEnumerator Start()
    {
        UnityWebRequest www = UnityWebRequest.Get(url);
        yield return www.SendWebRequest();
        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);     
        }
    }

}

猜你喜欢

转载自blog.csdn.net/weixin_43109909/article/details/105243361
今日推荐