- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- using UnityEngine;
-
- using System.Collections;
-
- using System.IO;
-
- public class LzhLog : MonoBehaviour
-
- {
-
- static int line = 0;
-
- public static void print(string info)
-
- {
-
- line ++;
-
- string path = Application.dataPath + “/LogFile.txt”;
-
- StreamWriter sw;
-
- //Debug.Log (path);
-
- if (line == 1)
-
- {
-
- sw = new StreamWriter(path, false);
-
- string fileTitle = “日志文件创建的时间 ” + System.DateTime.Now.ToString();
-
- sw.WriteLine (fileTitle);
-
- }
-
- else
-
- {
-
- sw = new StreamWriter (path, true);
-
- }
-
- string lineInfo = line + “\t” + “时刻 ” + Time.time + “: ”;
-
- sw.WriteLine (lineInfo);
-
- sw.WriteLine (info);
-
- Debug.Log (info);
-
- sw.Flush ();
-
- sw.Close ();
-
- }
-
- // Update is called once per frame
-
- void Update ()
-
- {
-
- // test
-
- if(Input.GetKeyDown(KeyCode.Space))
-
- {
-
- LexunLog.print (“测试信息”);
-
- }
-
- }
-
- }
复制代码 |
|