首页 > 解决方案 > 如何在 Unity iOS 构建中导出文件

问题描述

我想在我的 Unity iOS 版本中导出/共享一个 csv 文件。最令人满意的功能是创建文件后的共享弹出窗口,因为我不想让我的用户在 /var/mobile/Containers/Data/Application//Documents 中搜索(如 Application.persistentDataPath)。

此功能是否有任何解决方案/插件?

亲切的问候克里斯

标签: iosunity3d

解决方案


为此,我使用https://github.com/ChrisMaire/unity-native-sharing

将此添加为资产后,只需调用此函数:

NativeShare.Share(string body, string filePath, string url, string subject, string mimeType = "text/html", bool chooser, string chooserText)

这支持 Android 和 iOS - 并且 iOS 仅使用前 4 个参数 - 实际上你可以让它只使用 filePath 属性 - 所以如果你保存 csv 文件(在 Application.persistentDataPath 下),你可以简单地调用:

NativeShare.Share("", Application.persistentDataPath + "/myShinyCsvFile.csv", "", "", "", false, "");

推荐阅读