monokda.blogg.se

Unity pc build force resolution
Unity pc build force resolution










If you ever read any of my tutorials before, you will instantly recognize this static helper script: Otherwise you will end up disappointing your player by making him change it every session. Since we exposed orientation change as a button it should be stored and restored upon next startup. It’s time to start unveiling the edge cases of our dead simple implementation.įirst and the most obvious miss is an absence of setting saving. There are various workarounds on Unity forum, but, honestly speaking, all of them are far from perfect. On top of that Unity doesn’t provide an EventHandler for this “native” event.

unity pc build force resolution

You might be wondering - why to have that button at all instead of relying on the Device orientation change event? Whilst it is possible to make use of that, doing so will complicate the project quite a lot as you would need to account that the orientation change might happen on each and every scene. In reality you don’t actually see those weird intermediate frames when the scene is frozen in the opposite mode for a few seconds.īasically, that’s it, we are done here! If you think that it is too good to be true read on to find various edge cases hiding within this simple process of orientation change. Note! It looks way better on a phone comparing to the GIF. Let’s set up our scene, we will add a couple of images and a button to change the orientation: Building two separate versions of each scene is a tedious process! For this tutorial we will have Portrait as the default mode. Even though, in extreme cases you might want to create either a dedicated UI layer per orientation or even the whole scene, I personally would advise against that due to increased coding and maintenance complexity.

unity pc build force resolution

Scene preparationīefore you even add your first element on a scene you should decide which screen orientation will be the default one. There are three parts: Scene preparation, Coding and Edge cases. It is also worth mentioning that the project was tested on Android only.Īs always, project sources are available at GitHub, find the link at the end of the page. Like in my case, Zen Jigsaw needed support for Tablets right from the start but I could never find time (till last week) to implement it. This article assumes that your game IS suitable for both orientations. In this tutorial I will show you how to add support for both screen modes, also revealing a few edge cases that you might not have thought of. Obviously, by doing that a significant share of devices is left out.

unity pc build force resolution

Quite often developers choose to “ignore” the fact that there are two screen orientations available on the market - Portrait and Landscape, adding support for only one of them. Background Photos by Anni Roenkae from Pexels












Unity pc build force resolution