测试写日志的代码:
public class SDKEntrance : MonoBehaviour
{
private static string m_sdkFile;
public void CheckPermission()
{
WriteFile();
}
private static void ReadFile()
{
try
{
m_sdkFile = Path.Combine(Application.persistentDataPath, "sdk/sdk.txt");
if (!File.Exists(m_sdkFile))
{
return;
}
string[] strs = File.ReadAllLines(m_sdkFile);
if (strs != null)
{
for (int i = 0; i < strs.Length; ++i)
{
string[] colums = strs[i].Split('=');
int key = int.Parse(colums[0]);
int value = int.Parse(colums[1]);
}
}
}
catch (Exception ex)
{
}
}
private static void WriteFile()
{
try
{
string dir = Path.Combine(Application.persistentDataPath, "sdk");
m_sdkFile = Path.Combine(Application.persistentDataPath, "sdk/sdk.txt");
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
if (!File.Exists(m_sdkFile))
{
FileStream stream = File.Create(m_sdkFile);
stream.Close();
}
string[] strs = new string[2];
strs[0] = "hello";
strs[1] = "world";
File.WriteAllLines(m_sdkFile, strs);
}
catch (Exception ex)
{
}
}
}
比如我们的log,在persistentDataPath目录,安装好包,运行之后,选择Window->Devices and Simulators: