直接放代码吧
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();}}}