ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

unity设置外置文件,运行读取文件获取地址

unity设置外置文件,运行读取文件获取地址

直接放代码吧

 public static string url= "http://192.168.1.43:9100";//public static string url = "http://43.137.7.254:10028/server";private void Awake(){StartCoroutine(GetPath());}IEnumerator GetPath(){using (UnityWebRequest webRequest =UnityWebRequest.Get (Application.streamingAssetsPath +"/URLPath.txt")){// 发送请求yield return webRequest.SendWebRequest();// 检查是否有错误if (webRequest.result != UnityWebRequest.Result.Success){Debug.LogError("Error: " + webRequest.error);            }else{url = webRequest.downloadHandler.text;//Debug.Log("地址:" + url);          
                webRequest.Dispose();}}}

 

返回列表