public static string url; private IEnumerator ReadAddress() { string path = null; #if UNITY_EDITOR path = "file://" + Application.streamingAssetsPath + "/IpAddress.txt"; #endif #if !UNITY_EDITOR path = Application.streamingAssetsPath + "/IpAddress.txt"; #endif WWW www = new WWW(path); yield return www; if (www.isDone) { url = Encoding.UTF8.GetString(www.bytes); print("配置地址:" + url); } }
webgl平台的特殊性,无法直接file读取,只能通过www的形式读取,读取xml和json文件会有问题