GameTimeWather

GameTimeWather
This commit is contained in:
ALEXTANG
2022-08-29 13:26:49 +08:00
parent 9640b55a79
commit 052d81e039
2 changed files with 11 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ using UnityEngine;
public class DemoMain : MonoBehaviour public class DemoMain : MonoBehaviour
{ {
GameTickWatcher m_gameTimeWatcher = new GameTickWatcher();
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
@@ -16,6 +17,7 @@ public class DemoMain : MonoBehaviour
private void OnStartGame() private void OnStartGame()
{ {
Log.Debug("TEngineEvent.OnStartGame"); Log.Debug("TEngineEvent.OnStartGame");
m_gameTimeWatcher.ElapseTime(true);
} }
// Update is called once per frame // Update is called once per frame

View File

@@ -18,13 +18,19 @@
} }
/// <summary> /// <summary>
/// 用时 /// 用时检测
/// </summary> /// </summary>
/// <param name="logTime">是否输出日志</param>
/// <returns></returns> /// <returns></returns>
public float ElapseTime() public float ElapseTime(bool logTime = false)
{ {
long endTick = System.DateTime.Now.Ticks; long endTick = System.DateTime.Now.Ticks;
return (float)((endTick - m_startTick) / 10000) / 1000.0f; float ret = (float)((endTick - m_startTick) / 10000) / 1000.0f;
if (logTime)
{
Log.Debug($"GameTickWatcher ElapseTime :{ret} s");
}
return ret;
} }
public void LogUsedTime() public void LogUsedTime()