- Home /
Application.targetFrameRate returns -1 value
Hi I want to know what fps value is selected from player (30-60fps) but when I restarting game. start method returns -1 value how can I get value ? (maybe I can write somewhere and run with it but I want to easier way)
Answer by highpockets · Mar 24, 2019 at 06:56 PM
Ok, if the player has the ability to select a desired frame rate, you can use a static variable and save it to PlayerPrefs. Or you can use DontDestroyOnLoad() and pass the object which has your object and you will keep the objects state as it was before you restart. Hope that helps
static int targetRate;
void saveFrameRate()
{
PlayerPrefs.SetInt("FrameRate",targetRate);
}
function getFrameRate()
{
print( PlayerPrefs.GetInt("FrameRate");
}
may I get default value with this (what unity gives without player interaction)
Oops, I misunderstood the question. Read it too fast. Thought you were trying to get the actual frame rate. But -1 is returned when it is just set at the default and I think it is fine to do in the start method. $$anonymous$$y bad. The -1 means that it will intend to hit the default frame rate for each platform. If the player has the ability to input a desired frame rate, you can store that in a static variable and use player prefs to save it. Or you can use DontDestoryOnLoad() and you pass the object that has that variable you need to keep when restarting or jumping to another scene.
I will edit my answer. Sorry about that
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
ScrollableList best way to implement 0 Answers
How do I dynamically generate scenes? 5 Answers
script inside script execution order 0 Answers