• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CrowbarSka · Nov 02, 2018 at 02:37 PM · rotationdisplayorientationscreen orientation

Is it possible to rotate the entire screen orientation?

I want to rotate the entire display output for a PC standalone build, the same way you'd expect a mobile app to rotate when you rotate the device (i.e. "Screen.orientation").

The goal is to create a TATE mode so the game can be played on portrait monitors like an arcade cabinet game.

I've managed to achieve a similar effect by changing the Windows display settings, but I want to do it in-game so users don't have to do that whenever they play the game.

Is that even possible? And if so, how?

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by EgoAnt · Nov 02, 2018 at 08:38 PM

Certainly! If you don't want to change the screen resolution in Windows you could always just rotate your camera -90 on the z axis.


Your UI and controls would also have to be rotated accordingly.


One way to rotate your canvas would be to add a Grid Layout Group to it:
Grid Layout Group


I set the cell size to be my screen resolution and made sure I set the canvas to Screen Space Overlay.


Next I added a layout object that could be set to fill the whole screen and contain all my UI items. That item should be set to fill the whole screen. I added all my UI elements under it.


Finally I added a script to my canvas. The script has a "tateMode" boolean to track the current state and rotates the camera and UI to match. The script I made is below, and I've zipped the whole project and attached it so you can test it out. I think using this the controls could remain the same.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class FlipToTATE : MonoBehaviour {
 
     private bool tateMode;
     public GameObject myCamera;
     public GridLayoutGroup myGrid;
     public RectTransform layoutRotator;
 
     // Use this for initialization
     void Start () {
         tateMode = false;
 
     }
     
     // Update is called once per frame
     void Update () {
         if (Input.GetKeyUp(KeyCode.Space))
         {
             tateMode = !tateMode;
             if (tateMode)
             {
                 myCamera.transform.eulerAngles = new Vector3(0f, 0f, -90f);
                 layoutRotator.eulerAngles = new Vector3(0f,0f,90f);
                 myGrid.cellSize = new Vector2(Screen.currentResolution.height, Screen.currentResolution.width);
             }
             else
             {
                 myCamera.transform.eulerAngles = new Vector3(0f, 0f, 0f);
                 layoutRotator.eulerAngles = new Vector3(0f, 0f, 0f);
                 myGrid.cellSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);
             }
         }
     }
 }


[2]: /storage/temp/127100-tate-mode.zip


tate-mode.zip (59.8 kB)
grid-layout-group.png (13.2 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CrowbarSka · Nov 12, 2018 at 11:53 AM 0
Share

Hi, sorry for my slow reply, and thanks for the thorough explanation!

I tried this out and it works pretty well for the most part. The only issues I really had were that my game view doesn't seem to be the same aspect ratio when it's in TATE mode but I think that's a separate problem to do with the way I've hard-coded my camera's orthographic size value.

So, thanks! This works! :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

130 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

if x, make gameobject face player C# 1 Answer

How to change the way an object is facing when its rotation is 0,0,0? 2 Answers

How do I control particle orientation? (legacy vs shuriken) 3 Answers

Transmitting the Y and Z Rotation only (rigidbody)... How? 1 Answer

How to test Screen Orientation? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges