0
\$\begingroup\$

I have an Unity app that requires a stable fps in editor. The fps itself is really high anywhere from 200 to 280 the problem is that is not consistent. I tried to limit it with the code belove but it still goes up and down too much. So it is not a problem of how high it is but how stable it is. I did not test it in the build because I don't need to build this application I need it to work in editor.

 using UnityEngine; [ExecuteInEditMode] public class FrameRateLimiter : MonoBehaviour { [SerializeField] private int _target = 240; private void Start() { QualitySettings.vSyncCount = 0; } private void Update() { if (Application.targetFrameRate != _target) Application.targetFrameRate = _target; } } 
\$\endgroup\$
9
  • 1
    \$\begingroup\$ Why does your app require a stable framerate? And does it really need to be that high? \$\endgroup\$ Commented Nov 24, 2023 at 13:34
  • \$\begingroup\$ The higher the better, I just used 240 for a test but It should be ok at around 200 or maybe 180. Well it is not really a game it is a program where I record position as well as some other data about gameobjects to json and precision of these json file is affected by the framerate. So its not that much about high fps as it is about stable one. \$\endgroup\$ Commented Nov 24, 2023 at 13:43
  • \$\begingroup\$ Let me guess: You are building some kind of physics simulation and you want to log what objects do over time in that simulation? And you do that logging in Update, so you want those updates to happen in regular intervals? If my guess is correct, then I have a solution that might work for you. \$\endgroup\$ Commented Nov 24, 2023 at 13:46
  • \$\begingroup\$ It is more of a race simulation and I am applying that position data from to another project but yes I want it in regular intervals and I am using FixedUpdate. What is your solution? \$\endgroup\$ Commented Nov 24, 2023 at 13:54
  • 1
    \$\begingroup\$ What kind of yield instruction is that coroutine using? Maybe that's the code you should be posting, so we can find a better way to take the measurements. \$\endgroup\$ Commented Nov 24, 2023 at 15:11

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.