- Home /
How can I make android app run with less than 20 fps
I've been trying to make my game run with a specific frame, when I try to run on unity, it works exactly like I wanted, but when I put in my Android phone, the frame goes to 25 fps or more...
I tried to use Application.targetFrameRate, and I've already change AndroidUnityPlayer.cs
I'm using this code 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 = 12;
}
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;
}
}
}
What's the reason for targeting 12 fps? What are you trying to achieve?
The bad news is some devices have a forced vsync, this prevents apps from changing the FPS. No matter what you do the FPS cannot be changed on such devices, so it would really depend on which device specifically you're targeting?
Suddoha, this is a research! That's why I need every frame that I can catch the higher and the lowest..
I'm trying to run in android 4.1.2! I'm changing directly on Time.fixedDeltaTime; it seems to work now...
Answer by tng2903 · Sep 22, 2015 at 07:06 AM
You should separate between UI and logic, that way, you can have your logic run at whatever framerate you want, and the UI is update as fast as possible.
To update logic at a specified framerate, you could use InvokeRepeat, or custom made your own loop with do-while.
Hope this help
Answer by Joana15 · Sep 22, 2015 at 01:37 PM
I'm changing directly on Time.fixedDeltaTime; it seems to work now...