mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
GameTimeWather
GameTimeWather
This commit is contained in:
@@ -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
|
||||||
|
@@ -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()
|
||||||
|
Reference in New Issue
Block a user