- Home /
Bug when hiding resolution Dialog? (Settings get reset on startup)
Hi.
I am trying to hide the standard resolution and input dialog. Actually, yes, just hinding it is easy. But...
I have made an options manager that handles resolution , fullscreen and quality settings and also saves and loads them to / from an XML file. In the Start() function it has:
function Start () {
Application.targetFrameRate = 70;
ResetOptions(); // Load defaults
LoadOptions(); // Load XML file
ApplyOptions(); // Apply the settings
Debug.Log("Loaded Options");
}
And this works almost perfectly until I actually hide the resolution dialog. (Almost because the Unity splash screen loads in the default resolution and the resolution only gets reset afterwards. But nevermind that for now.) Once I set the dialog to hidden in the player settings the game always loads in the default resolution set in the player settings. The functions in Start() still get called Log message shows), but the resolution is not reset. It does work to apply the options again from the options GUI I made, but not anymore on startup.
I have looked in the playerPrefs in the registry to see what happens there. When setting the resolution in the options GUI the correct resolution gets saved to the playerPrefs. But on the next start they get reset to the default resolution again. This behavior does not occur when the resolution dialog is show, even if it's with a "hidden by default" dialog and shift-clicking the .exe. The dialog even shows the correct saved resolution then.
I tried executing the functions in Start() on loading the next scene (main menu), and this works, but only if the first scene is not "empty" (just a script to load the options manager and load the next scene).
tl;dr: When hiding the resolution dialog, the settings in playerPrefs always get reset to the defaults from the player settings.
I think this is basically the same as here link here (top related question) which did not get answered for quite some time. I'm at a loss here. This looks like a bug, but usually when I think it is a bug I am just overlooking something. ;)
Answer by Jesse Anders · Nov 02, 2010 at 12:24 AM
This may or may not be helpful, but here are two threads that appear to be on the same topic:
I'm trying to solve the same problem (or at least a similar one), but I haven't had any luck so far.
Took me some time to get back to this as there where more important things in the way. Your answer was at least helpful in showing me it's not me being stupid. :)
Answer by Markus Haeublein · Nov 30, 2010 at 03:51 PM
I've taken the following approach (for now): Have two scenes at startup, the first contains my options manager which loads and sets the resolution, and in the second scene a script that sets the resolution again. This only works with setting the resolution twice, if I only do it in the first scene it won't work (my guess is that the scripts don't have full control at this point, yet). This creates some screen-flickering at startup, and the unity splashscreen is still shown at the default res. I think I will file a bug report for this (Unity might be interested in having their splash screen shown pretty :) )
Answer by moka_one · Oct 10, 2012 at 05:31 PM
hey even if this is an old topic, in the man page you have this "A resolution switch does not happen immediately; it will actually happen when the current frame is finished." and it could mean that you'll have to set the resolution in a separated frame than the rest of the loads try it out with a bool for next frame use
Your answer
Follow this Question
Related Questions
How Do I Edit The Display Resolution Dialog? 0 Answers
GameObjects appear different on device than on Unity3d scene mode 2 Answers
Maximize window mode and alt tab 0 Answers
Display upscale filtering? 1 Answer