Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 eshan-mathur · Feb 13, 2014 at 11:36 PM · mobileaxisorientation

What are some strategies for supporting BOTH landscape and portrait mode on mobile?

I'm trying to create a game that is a top-down scrolling racer. Because it's top down and not side-view, gravity isn't a factor and the game should work fine in both landscape and portrait mode.

I want to enable that option and essentially have the game run the same way in both modes, but have the UI rotate according to the orientation.

The problem I'm having is that all my code was written using the assumption that the game would only be either landscape or portrait, which means that things don't rotate like they should when I change orientation. This is because obviously when you rotate the screen, things like positive X ALWAYS face towards the right side of the screen. In order to support both orientations, I'd need a way to tell Unity that positive X should now be the top of the screen instead (i.e. flipping from landscape to portrait).

Some things I was considering were asking the native device OS what orientation we were in, and then if we detected a change to portrait mode, actually set the Screen.Orientation property in Unity back to landscape so the positive X is preserved. Then manually rotate the UI to work for portrait.

That sounds pretty hacky though. Short of coding all my logic to support different axes, what are some strategies people have used to accomplish this kind of thing?

Illustration: alt text

illustration.jpg (13.7 kB)
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
1

Answer by alok.kr.029.hotmail · Aug 26, 2014 at 11:30 AM

what I have did is set two different screen for the landscape and potrate with a single main character and checked if the device is in landscape or not and accordingly set active the screens .. http://docs.unity3d.com/Manual/MobileAdvanced.html

Comment
Add comment · Show 2 · 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 chetan-rane · Sep 08, 2015 at 04:30 AM 0
Share

I am also searching for the same ans

So far this is what i am doing but i am curious to know if it has better way (especially with new ui system from 4.6).

Because the major headache with this approach is if we need to maintained two seperate copies of UI (one for landscape and one for portrait). When there is any changes required to do then our work get doubled :(

avatar image unity_eaKm_7FNf4Uaww · May 30, 2019 at 11:51 AM 0
Share

did you got any solution for these?

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.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Harry Potter's Wand problem, MouseLook script 2 Answers

Joystick triggers directed function 1 Answer

Mobile Orientation / input.acceleration problems 0 Answers

Rotate object to match phone's orientation 1 Answer

How to know if finger is on joystick if it is at horizontal & vertical zero 0 Answers


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