VR FPS 帧率显示
- 找到你的VR Camera(或Center Eye Camera),创建 UI->Canvas
设置Render Mode为 World Space;
设置位置为(0,0,0.5)(push it out in front of the camera)
设置Scale为(0.001,0.001,0.001) - 点击Canvas,创建UI->Text
- Text加入下面的代码
点击”F”键可以显示隐藏
Note: It uses the new fancy Unity 5 Time.unscaledDeltaTime property !
转载来自:http://talesfromtherift.com/vr-fps-counter/1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162using UnityEngine;using UnityEngine.UI;// Display FPS on a Unity UGUI Text Panel// To use: Drag onto a game object with Text component// Press 'F' key to toggle show/hidepublic class TextFPSCounter : MonoBehaviour{public Text text;public bool show = false;private const int targetFPS =#if UNITY_ANDROID // GEARVR60;#else75;#endifprivate const float updateInterval = 0.5f;private int framesCount;private float framesTime;void Start(){// no text object set? see if our gameobject has one to useif (text == null){text = GetComponent<Text>();}}void Update(){if (Input.GetKeyDown(KeyCode.F)){show = !show;}// monitoring frame counter and the total timeframesCount++;framesTime += Time.unscaledDeltaTime;// measuring interval ended, so calculate FPS and display on Textif (framesTime > updateInterval){if (text != null){if (show){float fps = framesCount / framesTime;text.text = System.String.Format("{0:F2} FPS", fps);text.color = (fps > (targetFPS - 5) ? Color.green :(fps > (targetFPS - 30) ? Color.yellow :Color.red));}else{text.text = "";}}// reset for the next interval to measureframesCount = 0;framesTime = 0;}}}