小编Noo*_*mer的帖子

在 StreamingAssetsPath 上读取和写入文件

这就是我在 android 中读取文本文件的方式。

#if UNITY_ANDROID
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
// Android only use WWW to read file
        WWW reader = new WWW(full_path);
        while (!reader.isDone){}

        json = reader.text;

        // PK Debug 2017.12.11
        Debug.Log(json);
 #endif
Run Code Online (Sandbox Code Playgroud)

这就是我从电脑读取文本文件的方式。

#if UNITY_STANDALONE
        string full_path = string.Format("{0}/{1}", Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
        StreamReader reader = new StreamReader(full_path);
        json = reader.ReadToEnd().Trim();
        reader.Close();
#endif
Run Code Online (Sandbox Code Playgroud)

现在我的问题是我不知道如何在移动设备上编写文件,因为我在独立设备上这样做

#if UNITY_STANDALONE
        StreamWriter writer = new StreamWriter(path, false);
        writer.WriteLine(json);
        writer.Close();
 #endif
Run Code Online (Sandbox Code Playgroud)

帮助任何人

更新的问题

这这是我需要获取的流媒体资产文件夹中的 json 文件

c# android json unity-game-engine web

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

c# ×1

json ×1

unity-game-engine ×1

web ×1