Unity - 项目中的文件 .txt 隐藏到 .apk 中?

Unity - files .txt in Project are hidden into the .apk?

如果我在 Android 项目的项目文件夹中有一个 .txt 文件,并且我将此项目构建为 .apk。用户可以从设备资源管理器访问此文件还是隐藏在 .apk 中?

(我为我的英语道歉)

Unity 将生成一个 .apk 文件。

如果满足以下条件,您的 .txt 文件将被烘焙:

  • 它被场景中的某物引用
  • 它在 Resources 文件夹中

您还可以访问 streamingAssetsPath(只读): https://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html

和 persistentDataPath(这是一个您可以 read/write 数据的文件夹,您的用户可以访问...但您只能在安装后访问此文件夹): https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

要在 Android 上读取 streamingAssets 中的文件,您需要使用 WWW class 但文档中解释了所有内容(带有示例)。

阅读本文以了解您是否真的需要使用 Resources 文件夹,或者最好使用 streamingAssetsPath: https://unity3d.com/learn/tutorials/topics/best-practices/resources-folder

如果您想了解其中的区别,我建议您阅读以下内容: https://forum.unity.com/threads/resources-vs-streamingassets-for-mobile.494804/