|
|
- LuaFPS = LuaFPS or {}
- local LuaFPS = LuaFPS
- LuaFPS.FPS = 0
- LuaFPS.total_frames = 0
- LuaFPS.total_time = 0
-
- LuaFPS.FIXED_FPS = 0
- LuaFPS.fixed_total_frames = 0
- LuaFPS.fixed_total_time = 0
- local Time = Time
- function LuaFPS.Update()
- LuaFPS.total_frames = LuaFPS.total_frames + 1
- LuaFPS.total_time = LuaFPS.total_time + Time.unscaledDeltaTime
- if LuaFPS.total_time >= 1 then
- LuaFPS.SetFPS()
- end
- end
-
- function LuaFPS.FixedUpdate()
- LuaFPS.fixed_total_frames = LuaFPS.fixed_total_frames + 1
- LuaFPS.fixed_total_time = LuaFPS.fixed_total_time + Time.fixedDeltaTime / Time.timeScale
- if LuaFPS.fixed_total_time >= 1 then
- LuaFPS.SetFixedFPS()
- end
- end
-
- function LuaFPS.SetFPS()
- LuaFPS.FPS = LuaFPS.total_frames
- LuaFPS.total_frames = 0
- LuaFPS.total_time = 0
- GlobalEventSystem:Fire(EventName.SET_FPS,LuaFPS.FPS)
- end
-
- function LuaFPS.SetFixedFPS()
- LuaFPS.FIXED_FPS = LuaFPS.fixed_total_frames
- LuaFPS.fixed_total_frames = 0
- LuaFPS.fixed_total_time = 0
- GlobalEventSystem:Fire(EventName.SET_FIXED_FPS,LuaFPS.FIXED_FPS)
- end
- UpdateBeat:Add(LuaFPS.Update)
- -- FixedUpdateBeat:Add(LuaFPS.FixedUpdate)
|