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
2
Question by Avestas · Mar 30, 2014 at 04:22 PM · rotationmobilescreenorientationunity remote

How to test Screen Orientation?

Hi there, I got a small problem:

In my game, I need to know the orientation of the device (though it should not autorotate etc, just read access). I am trying to access it via :

Screen.orientation

I am testing this with Unity Remote und Unity 4.3., but

 print(Screen.orientation);

only gives me: "Portrait". (even if I explicitly set the Player Settings to landscape only).

The Player Settings are already configured (Auto-Rotation enabled, all 4 orientations enabled).

I suppose Unity Remote does not work properly, but I have to use it for testing purposes. Anyone got an idea?

Thanks in advance and greetings!

Comment
Add comment · Show 1
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 SmallLion · Feb 26, 2021 at 03:39 PM 1
Share

You can also use Device Simulator:D

3 Replies

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

Answer by Bunny83 · Mar 31, 2014 at 05:07 PM

The Unity Remote app is very limited since it's "just" a remote control for the Unity Editor. A lot things work differently on the actual device.

Besides that Screen.orientation just let you get / set the orientation of the (virtual) screen. To get the orientation of the device you should use Input.deviceOrientation as the screen in the editor can't be rotated.

Comment
Add comment · Show 6 · 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 Avestas · Apr 01, 2014 at 11:21 AM 0
Share

Thanks, that is exactly what I needed!

avatar image Bunny83 · Apr 02, 2014 at 03:18 AM 0
Share

@Avestas:
Could you tick the answer as solution so the question is marked as solved?

avatar image DiebeImDunkeln · Mar 12, 2015 at 10:38 AM 0
Share

Input.deviceOrientation is nice, but the problem is that it also shows results like FaceUp, FaceDown etc. . This is not helpful if I like to check if the screen is LandscapeLeft or LendscapeRight, if my tablet for example lay's flat on the table.

avatar image Bunny83 · Mar 12, 2015 at 01:03 PM 0
Share

@DiebeImDunkeln: If the tablet lies flat on the table, how should the tablet know where you are relative to the tablet? You could sit:

  • at the bottom (in which case you'd expect it to be in Portrait)

  • at the right side (-> LandscapeRight)

  • at the top side (-> PortraitUpsideDown)

  • at the left side (-> LandscapeLeft)

Those 4 situations are possible when the tablet lies flat on the table. If you (the person) walk around the table where the tablet sits, how should the tablet know where you are at the time?

The tablet uses the acceleration sensor (and it senses the gravitational pull of the earth) to setup a reference frame in the world. All it knows from that information is where "down" is. Based on that information it can deter$$anonymous$$e those 6 (+1) device orientations in the world:

  • $$anonymous$$ (in case no acc sensor is available)

  • Portrait (gravity pulls to the bottom)

  • PortraitUpsideDown (gravity pulls to the top)

  • LandscapeLeft (gravity pulls to the left side)

  • LandscapeRight (gravity pulls to the bottom)

  • FaceUp (gravity pulls to the back side)

  • FaceDown (gravity pulls to the front side)

Even if the device has a gyroscope, it wouldn't make much sense to return an orientation towards "north" or something like that since you're probably not in the "north direction" of the device.

avatar image DiebeImDunkeln · Mar 12, 2015 at 01:10 PM 0
Share

in my case I solved the orientation problem with a switch orientation button which is visible on all screens.

You can click it and switch between LandscapeLeft and LandScapeRight. In out game it makes no sense to offer portrait mode.

We have 2-6 players who sit around the tables which lay's on the table. It's a round based board game with arcade $$anonymous$$i games. The $$anonymous$$i games are the reason why we don't offer portrait mode.

Show more comments
avatar image
0

Answer by ava4414 · Mar 30, 2014 at 07:47 PM

you can show it in a GUI label intead of console, and then you put your apk in you device and the test it .

http://docs.unity3d.com/Documentation/ScriptReference/GUI.Label.html

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 Avestas · Mar 31, 2014 at 01:22 PM 0
Share

Well, the problem is, I do not have an Apple $$anonymous$$ccount (yet). That's why I can't test it on the actual device :S

Any other suggestions?

But thanks anyway!

avatar image
0

Answer by CrandellWS · Feb 25, 2021 at 08:30 PM

so i was just wanting a quick easy way to view how my project might look based on orientation in the Unity editor before i built my project.

i came up with this method hack to still be able to get the desired results in the editor...

      public ScreenOrientation myScreenOrientation {
          get{
             #if UNITY_EDITOR
                 if(Screen.height > Screen.width){
                     return ScreenOrientation.Portrait;
                 } else {
                     return ScreenOrientation.Landscape;
                 }
             #else
                 return Screen.orientation;
             #endif
          }
      }


then instead of using Screen.orientation i use myScreenOrientation

I did not do this for Input.deviceOrientation because this may not be the same as what the screen orientation is... for example they could be laying in a bed with the phone overhead and it would read as facedown which is nether landscape or portrait and did not help me with my ui layouts

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

24 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

Related Questions

How do I change orientation without reorienting? 0 Answers

Unity Remote and Screen Orientation 2 Answers

How to have a scene rotate with the device orientation 0 Answers

l want my game object to appear in a location and change when screen size changes? 0 Answers

For mobile games, how could you divide the screen into three buttons vertically? 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