我是靠谱客的博主 直率睫毛膏,这篇文章主要介绍unity lua实现fps,现在分享给大家,希望可以做个参考。

local UIManager=require"uimanager"

local m_UpdateInterval=1
local m_Accum=0
local m_Frames=0
local m_TimeLeft=0

local function update()
    m_TimeLeft = m_TimeLeft-Time.deltaTime
    m_Accum = m_Accum+(Time.timeScale / Time.deltaTime)
    m_Frames=m_Frames+1
    if (m_TimeLeft <= 0) then        
        if UIManager.isshow("dlguimain") then
            local fps = m_Accum/m_Frames
            local str = string.format("FPS:%.2f",fps)
            UIManager.call("dlguimain","RefreshFPS",str)   
        end
        m_TimeLeft = m_UpdateInterval
        m_Accum =0
        m_Frames = 0  
    end  
end

local function init()
    m_TimeLeft = m_UpdateInterval
    gameevent.evt_update:add(update)
end

return{
    init = init,
    update = update,
}

最后

以上就是直率睫毛膏最近收集整理的关于unity lua实现fps的全部内容,更多相关unity内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(112)

评论列表共有 0 条评论

立即
投稿
返回
顶部