Unity3D 大型游戏 最后一站 源码 部分重点 显示FPS
2017-03-14 09:46
537 查看
本文固定链接:http://blog.csdn.net/u013108312/article/details/62037298
Unity3D 显示FPS脚本。
Unity3D 显示FPS脚本。
using UnityEngine; using System.Collections; public class ShowFPS : MonoBehaviour { public static ShowFPS Instance { private set; get; } void OnEnable() { Instance = this; } void OnDisable() { Instance = null; } public float f_UpdateInterval = 0.5F; private float f_LastInterval; private int i_Frames = 0; private float f_Fps; private GUIStyle style = new GUIStyle(); public float sSPing { set; get; } public float cSPing { set; get; } void Start() { Application.targetFrameRate = 300; f_LastInterval = Time.realtimeSinceStartup; i_Frames = 0; style.fontSize = 10; style.normal.textColor = new Color(0, 255, 0, 255); } void OnGUI() { GUI.Label(new Rect(0, 0, 200, 200), "FPS:" + f_Fps.ToString("f2"), style); GUI.Label(new Rect(0, 10, 200, 200), "sSPing:" + sSPing.ToString("f2"), style); GUI.Label(new Rect(0, 20, 200, 200), "cSPing:" + cSPing.ToString("f2"), style); } void Update() { ++i_Frames; if (Time.realtimeSinceStartup > f_LastInterval + f_UpdateInterval) { f_Fps = i_Frames / (Time.realtimeSinceStartup - f_LastInterval); i_Frames = 0; f_LastInterval = Time.realtimeSinceStartup; } } }
相关文章推荐
- Unity3D 大型游戏 最后一站 源码 部分重点ResourceManager(2)
- Unity3D 大型游戏 最后一站 源码部分重点 对象池GameObejctPool(4)
- Unity3D 大型游戏 最后一站 源码 部分重点ResourceManager(2)
- Unity3D 大型游戏 最后一站 源码 部分重点 英雄玩家同步移动(14)
- Unity3D 大型游戏 最后一站 源码 部分重点 GameView-BaseWindow(16)
- Unity3D 大型游戏 最后一站 源码 部分重点ResourceManager2(5)
- Unity3D 大型游戏 最后一站 源码 部分重点匹配战斗(三)(12)
- Unity3D 大型游戏 最后一站 源码 部分重点NetworkManager(二)(8)
- Unity3D 大型游戏 最后一站 源码 部分重点WindowManager(1)
- Unity3D 大型游戏 最后一站 源码 部分重点NetworkManager(三)(9)
- Unity3D 大型游戏 最后一站 源码 部分重点匹配战斗(二)(11)
- Unity3D 大型游戏 最后一站 源码 部分重点GameStateManager(6)
- Unity3D 大型游戏 最后一站 源码 部分重点 英雄释放技能(15)
- Unity3D 大型游戏 最后一站 源码 部分重点匹配战斗(一)(10)
- Unity3D 大型游戏 最后一站 源码 部分重点NetworkManager(一)(7)
- Unity3D 大型游戏 最后一站 源码 部分重点 整体框架(3)
- Unity3D 大型游戏 最后一站 源码 部分重点ResourceManager(2)
- Unity3D 大型游戏 最后一站 源码 部分重点 GameView-LoginWindow(17)
- Unity3D 大型游戏 最后一站 源码 部分重点匹配战斗(四)(13)
- Unity3D 大型游戏 商业游戏(Diablo War)源码 部分重点(1)