I want to lock the framerate of my scene to 30fps, then I learned from this post that fps info in Editor Stat isn't reliable, that's why my fps is still around 100. This is my script for setting the framerate (vSync also has been set into Don't Sync) :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TargetFramerate : MonoBehaviour {
public int frame_rate = 30;
void Start () {
}
void Awake (){
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = frame_rate;
}
void Update () {
if (frame_rate != Application.targetFrameRate) {
Application.targetFrameRate = frame_rate;
}
}
}
But it doesn't work. Where should I put this script ? The description says in any GameObject will be ok, so I put in one of my GameObject with camera attached on it. By the way, I'm also using SteamVR camera script for my GameObjects (for HMD device), is it affecting this script ?
[UPDATE]
I posted the same question on Reddit, and got several feedbacks. So, the code that I used before from Wiki Unity 3D - FramePerSecond is outdated and using deprecated OnGUI system. As of now I'll try to use FPSCounter from the Standard Assets and see if it works.
Here's how it looks like on the scene using FPSCounter from Standard Assets, it works on the Game tab, but it doesn't show on the device (I'm using HMD- HTC Vive).
Also, my framerate lock code above doesn't seem to work, since the FPS is still reaching 90fps. Any advice ?