- Home /
Screen.SetResolution causes a glitch for 1 frame, any way to avoid it?
I'm on iOS and Android... trying a lower resolution to reduce pixels drawn, but.... there is a big glitch when changing resolution... it shows the last frame rendered shrunk down, for 1 frame, before rendering properly the next frame....
Could probably hide this by fading screen to black or some other plain color then doing the change... but that is a poor solution, and adds extra time into loading sequence....
So, is there a way to call Screen.SetResolution() without a rendering glitch ? (unity 5.6.3 iOS & Droid)
Thanks in advance for any help.
Answer by Diukrone · Jan 16, 2018 at 12:54 AM
As you not posted some code, please consider to check the SetResolution API!
no code is required.. its a 1 function call. The problem is with Unity, and is there a solution to avoid the rendering glitch that happens when you try to use the function Screen.SetResolution(width, height);
Answer by NorthStar79 · Jan 16, 2018 at 06:33 AM
Calling set resolution after frame rendering done will be a solution, I did not tried but i highly suggest you take a look at this documentation page about OnPostRender
EDIT : i think OnPreRender can be a better solution. give it a shot.
Thanks, yep tried OnPostRender, but it takes several frames on older systems... so you see a glitched screen for maybe 1/4 second on Android s3
if it takes several frames, I am afraid fade out and fade in is the best way to hide that glitch from the player I guess.
Thanks again... trying something like this.... ...wait for end of frame.... ...disable scene cameras (to leave last good rendered screen up) ...change SCreen.SetResolution(w,h) ...optional wait a bit here, or wait for something.... end of frame, pre or post render ? ...then turn cameras back on ...its not working yet but... have hopes...
Answer by JonPQ · Jan 24, 2018 at 05:00 PM
had to work around... by doing the screen fade in first scene, set camera to not clear, just draw a polygon over whole screen, that fades from alpha 0 to 255 (this fades out the splash screen) and gives a blank screen, then switch res, then wait a few frames, then turn on a new screen below the now opaque poly/sprite/image. then fade the opaque one (which is on top) back down to alpha 0, to reveal the new image, at new resolution.
added a fade to flat color, change res, pause, then un-fade, to reveal scene.
Few things learned though.... did get it working on S3, but S5 showed corruption after turning off all cameras. Also required some odd timing waits, which was deemed unreliable for compatibility. Trying the setResolution in preRender or PostRender would crash some droid devices.
Update:- Since release of iPhone X and tall aspect devices with no home button... the home button has migrated to in icon at the bottom of the screen instead.. some devices seem to now add extra time into their start-up sequence to fade out the home button. This can also mess with the timing of the above fix, and re-introduce a glitch in display, when swapping resolutions
Trying the setResolution in preRender or PostRender would crash some droid devices.
That's odd, I will keep this in $$anonymous$$d, thank you for sharing your progress
Your answer
Follow this Question
Related Questions
Halo rendering through objects? 0 Answers
Objects are not visible until the camera gets closer. 1 Answer
Is it possible to render in Unity without the editor/scene/player being visible? 0 Answers
Unity2D strange green line under sprites 0 Answers
Native rendering plugin D3D11 device type not being set in x86 builds. 0 Answers