6
I’m trying to manipulate the frame rate (frame rate) within a Unity scene, when I run it on the Unity platform, it works with the particular frame value I sent. However, when I pass it to my cell phone, it varies from 25 to 30 fps.
-> I already changed v Sync Count -> don’t use
-> I’ve changed the frame directly on Androidunityplayer.Cs
-> I’ve 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;
        }
    }
}
						
From this model I got the values I wanted inside the desktop. I also did directly in the classes that capture the scene by the Awake() function. But I was able to get the desired values by changing time settings in Unity.
– Joana