【发布时间】:2018-10-06 00:57:08
【问题描述】:
我需要帮助解决我们系统中的问题。我们正在使用 Unity 和 Visual Studio C# 来创建仅使用凝视控件(无控制器)的移动 VR 游戏。我们需要找到一种将调试日志写入文本文件并保存到 android 内部存储的方法。提前感谢您的帮助!
下面是我们的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine;
public class VRPlace : MonoBehaviour
{
...
void OnTriggerEnter(Collider other)
{
string path = "Assets/Resources/PlacesLog.txt";
StreamWriter testing = new StreamWriter(path, true);
if (other.gameObject.name == "Hospital")
{
GameObject otherObj = other.gameObject;
Debug.Log("Triggered to: " + otherObj);
}
testing.WriteLine(other.gameObject.name);
testing.Close();
}
}
【问题讨论】:
-
您遇到了什么问题?您可以毫无问题地写入 Application.PersistentDataPath 目录。
-
我们在安卓设备的内部存储中找不到.txt文件
-
如果您在通过 USB 连接时无法查看文件,这可能会对您有所帮助。 stackoverflow.com/questions/40389108/… 简答,重启设备。更长的答案,编写一个插件来更新媒体存储。 stackoverflow.com/questions/3300137/…
-
谢谢,我们会试试的
标签: c# android unity3d google-vr