其他分享
首页 > 其他分享> > u3d:webgld读取外部配置文件

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

标签:www,u3d,读取,配置文件,url,streamingAssetsPath,webgld,Application,path
来源: https://www.cnblogs.com/zbyglls/p/15014670.html