u3d:webgld读取外部配置文件

  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文件会有问题

posted @ 2021-07-15 11:22  怪力~乱神  阅读(523)  评论(0编辑  收藏  举报