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(); } } }

浙公网安备 33010602011771号