• 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
3
Best Answer

Answer by AaronXRDev · 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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

128 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

Related Questions

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? 3 Answers

orienting player in one direction 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges