Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
20
Question by jwiard · Jan 13, 2014 at 01:14 AM · settingsorientation

Android: How do I force only portrait orientation?

The only setting I can find regarding orientation in the editor is in Player Settings, under Android, there is a Default Orientation option. But that doesn't prevent someone from rotating their device and having autorotate change the orientation of the game.

I thought there was an option somewhere to disable certain orientations? I'm having a hard time finding this, and searching here/google for a solution is surprisingly unhelpful. There is a lot of talk about changing the orientation via code and in xml manifests, but how do I do it in the editor?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
57

Answer by Disastercake · Apr 29, 2015 at 07:50 PM

In Unity 5 I found the options for disabling different orientations under the Edit >> Project Settings >> Player.

Then under "Resolution and Presentation" group you can see the "Orientation" sub group, then you will find the relevant "Default Orientation" option. You can set it to Portrait from the dropdown menu here to force orientation.

This disabled the auto orientation, so rotating the phone around will not cause the orientation to change.

Comment
Add comment · Show 3 · 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 Bunny83 · Apr 29, 2015 at 09:38 PM 3
Share

Hmm, the 4 checkboxes for the 4 orientations are there for quite some time now. I think even Unity 3.5 had them already.

Personally I hate when developers do this. You need to have a very good reason why you don't allow upside-down rotation. For example it wouldn't make sense to allow upside down in one of those pointless ibeer apps as it would actually break it's function / purpose.

I play all portrait games on my Nexus upside down because most the time i have the power cord attached at the bottom and it always get's in the way. I still be able to play any portrait game upside down by locking the rotation before i start the game, however i prefer when the app supports this (like subway surfers for example).

Just enable autorotate and restrict the orientations to portrait. If you have trouble that it doesn't rotate at start, simply set the orientation in Start() to the best fitting portrait orientation.

btw you can set all those things inside the Screen class from script. You might want to use Input.deviceOrientation to deter$$anonymous$$e how the user hold the device at startup. With a few lines of code you can get the perfect starting orientation ^^

avatar image tsgrcfx Bunny83 · Nov 28, 2017 at 03:18 PM 1
Share

real talk, Bunny

avatar image amazingjaba · Apr 27 at 11:14 AM 0
Share

This is STILL RELEVANT in Unity 2020.3.23f1.

Thank you for the solution.

avatar image
2

Answer by lulitha · Jul 14, 2020 at 04:01 PM

how do i stop rotate only one scence?

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 RicoAlbe · Jul 17, 2020 at 07:26 AM 0
Share

You can just individually set autorotation for different orientations. Just set them to false when you load that scene and set them back to true when you unload it.

They're accessible as: - Screen.autorotateToLandscapeLeft - Screen.autorotateToLandscapeRight - Screen.autorotateToPortrait - Screen.autorotateToPortraitUpsideDown

avatar image
0

Answer by Myron145 · Apr 29 at 12:11 PM

I want to use all activities in my form in landscape or portrait. When user select orientation - this is valid for all activities. Tried with "behind" option orientation. According to Google - orientation will depend on previous activity. DinarRecaps.com

My first activity use setRequestedOrientation to set selected from user orientation.

Next activities have to follow same orientation. Do I have to put setRequestedOrientation in their code too? Or really on 'behind' parameter in manifest? Putting setRequestedOrientation may be cause onCreate again?

UPDATE: Tried "portrait" and setRequestedOrientation() - result is onCreate was called 2 times.

Problem is in next activity -> because of "portrait" in first activity - android started next activity with same orientation. It ignores "landscape" orientation which was set by me.

Comment
Add comment · 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

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

23 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

Related Questions

A node in a childnode? 1 Answer

Unity in iOS Tab Bar Controller Orientation Issue 0 Answers

How to make an in-game settings menu? 1 Answer

set up default NewProject location + folders 5 Answers

Reorient the construction worker 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