源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

41 行
1.1 KiB

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)