提交 0c02304c 编写于 作者: T tanghai 提交者: GitHub

Merge pull request #20 from bsyx/dev01

修改日志路径,兼容手机平台
......@@ -10,20 +10,19 @@ namespace Model
private static readonly StreamWriter error;
#if UNITY_EDITOR
private static bool IsNeedFlush = true;
#else
private static bool IsNeedFlush = true;
#endif
public static bool IsNeedFlush = true;
private static string dirName = "Logs";
private static string infoFileName = "/Log-Client-Info.txt";
private static string errorFileName = "/Log-Client-Error.txt";
static Log()
{
if (!Directory.Exists("./Logs"))
string dirPath =PathHelp.AppHotfixResPath + dirName;
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory("./Logs");
Directory.CreateDirectory(dirPath);
}
info = new StreamWriter("./Logs/Log-Client-Info.txt", false, Encoding.Unicode, 1024);
error = new StreamWriter("./Logs/Log-Client-Error.txt", false, Encoding.Unicode, 1024);
info = new StreamWriter(dirPath+ infoFileName, false, Encoding.Unicode, 1024);
error = new StreamWriter(dirPath+ errorFileName, false, Encoding.Unicode, 1024);
}
public static void Warning(string msg)
......

using System;
using System.Text;
using UnityEngine;
namespace Model
{
public static class PathHelp
{ /// <summary>
///应用程序外部资源路径存放路径(热更新资源路径)
/// </summary>
public static string AppHotfixResPath
{
get
{
string game = Application.productName;
string path = AppResPath;
if (Application.isMobilePlatform)
{
path = $"{Application.persistentDataPath} { "/"} {game} {"/"}";
}
return path;
}
}
/// <summary>
/// 应用程序内部资源路径存放路径
/// </summary>
public static string AppResPath
{
get
{
string path = string.Empty;
switch (Application.platform)
{
case RuntimePlatform.Android:
path = $"{"jar:file://"}{Application.dataPath}{"!!/assets/"}";
break;
case RuntimePlatform.IPhonePlayer:
path = $"{Application.dataPath}{"/Raw/"}";
break;
default:
path = $"{Application.dataPath}{"/StreamingAssets/"}";
break;
}
return path;
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册