赞
踩
每秒传输帧数(Frames Per Second)
- using UnityEngine;
- using UnityEngine.UI;
-
- public class FpsUI : UIBase
- {
- private Text FpsText;
- private float time;
- private int frameCount;
- private void Awake()
- {
- InitUI();
- }
- public override void InitUI()
- {
- FpsText = GetComp<Text>("FpsText");
- }
- void Update()
- {
- time += Time.unscaledDeltaTime;
- frameCount++;
- if (time >= 1 && frameCount >= 1)
- {
- float fps = frameCount / time;
- time = 0;
- frameCount = 0;
- FpsText.text = fps.ToString("f2");//#0.00
- FpsText.color = fps >= 20 ? Color.white : (fps > 15 ? Color.yellow : Color.red);
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。