- Home /
Only Rotate UI HUD on orientation change.
So I am creating a mobile infinite runner which can be played irrespective of the screen orientation[It is set to 'Portrait' & NOT to 'Auto Rotate'].
The game works fine except for the reason that I am having problems layouting my HUD elements[Score and health]. Using 'Input.deviceOrientation', I am rotating the elements but cannot reposition them accordingly.
Some approaches that I thought of are :
Rotate and realign every HUD elemnt.
Rotate the parent canvas which holds these HUD elements.
Create 2 cameras : One for the HUD elements and another for the game. [Not sure how though].
I am attaching 2 images of what I want to achieve.
Any help would be appreciated. Thanks in advance. :)
Hi,
The solution i'd use would be to duplicate your canvas HUD, move everything manually so it's fine to you and then activate one canvas or the other based on the orientation.
That could be done, but then it would stop me from any sort of animation on the canvas elements.
Well, you would have to double the animations too ^^
Your ideas 1 and 2 are not good solutions to me: you'll have to find all the new positions and size of your elements, make good looking animations to change that, adapt animations to the new sizes (like if you translate a button to put it outside of the screen, you'd need 106px in one case and maybe like 212px in the other case ... so it would be easier and shorter in time to double everything
About number 3 i'm not sure what you wanna do with your other camera ?