| 123456789101112131415161718192021222324252627282930313233343536 |
- local SUIFPS = {}
- local nTime = 0
- local nFrameCount = 0
- local function UpdateFPS()
- local textFpsCom = SUIFPS.rootPanel.transform:GetComponent("Text")
- nTime = nTime + CS.UnityEngine.Time.unscaledDeltaTime;
- nFrameCount = nFrameCount + 1
- if (nTime >= 1 and nFrameCount >= 1) then
- local fps = nFrameCount / nTime
- nTime = 0;
- nFrameCount = 0;
- textFpsCom.text = string.format("fps_1: %.2f", fps);
- end
- end
- function SUIFPS.Awake(luaRoot)
- SUIFPS.luaRoot = luaRoot
- local canvas = CS.UnityEngine.GameObject.Find("Canvas")
- SUIFPS._rootCanvas = canvas
- local prefabPanelGaming = LoadResource("Prefabs/UI/SUIFPS.prefab")
- local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanelGaming, SUIFPS._rootCanvas.transform)
- SUIFPS.rootPanel = rootPanel
- CS.UnityEngine.Object.DontDestroyOnLoad(SUIFPS.rootPanel)
- end
- function SUIFPS.Update()
- UpdateFPS()
- end
- return SUIFPS
|