I'm trying to manipulate the frame rate within a unity scene, when I run it on the unity platform, it works with the given frame value I gave it. However, when I switch it to my phone, it varies from 25 to 30 fps.
- > I already changed the v sync count - > do not use
- > I already changed the frame directly on AndroidUnityPlayer.cs
- > I've already used Time.captureFramerate
- > And I'm using this code to change the frame:
using UnityEngine;
using System.Collections;
public class FPSScript : MonoBehaviour {
public float updateInterval = 0.5F;
private float lastInterval;
private int frames = 0;
private float fps;
void Start() {
lastInterval = Time.realtimeSinceStartup;
frames = 0;
Application.targetFrameRate = 10;
}
void OnGUI() {
GUILayout.Label("" + fps.ToString("f2"));
}
void Update() {
++frames;
float timeNow = Time.realtimeSinceStartup;
if (timeNow > lastInterval + updateInterval) {
fps = frames / (timeNow - lastInterval);
frames = 0;
lastInterval = timeNow;
}
}
}