【问题标题】:Unity: Open local file containing a space for windowsUnity:打开包含windows空间的本地文件
【发布时间】:2017-12-20 14:17:30
【问题描述】:

我尝试打开名称包含空格的图像文件失败。

我使用以下调用:

WWW www = new WWW(url);

地点:

url = "C:\Users\user\Documents\Files\Thumbnails\sample image.png";

出现红色问号而不是图像。

打印 www.error 时也会出现 404 错误。

如果我使用另一个没有空格的 .png 文件 (sampleimage.png),它可以完美运行。在 Windows 和编辑器上它也很好用。

所以我尝试用 %20 替换空格,但出现错误“无法加载文件”。

我也尝试过将WWW.EscapeURL 应用于文件名...但没有任何效果。

【问题讨论】:

    标签: image url unity3d


    【解决方案1】:

    尝试使用逐字字符串和file://前缀:

    string filePrefix = @"file://";
    string url = @"C:\Users\user\Documents\Files\Thumbnails\sample image.png";
    

    【讨论】:

    • 我之前尝试过,现在重试,结果相同:www.error is 404 Not Found
    • 只有当我将 unity 更新到 2017.2 和 2017.3 时才会发生这种情况。我在 2017.1 上尝试过,它在空间上运行良好
    • 你用file://前缀试过了吗?
    • 它适用于 file:// 。我之前用过不正确。您可以为其他人编辑答案吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多