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
1
Question by rednax20 · May 15, 2014 at 02:11 AM · rotationiosscreenorientation

Screen.orientation absolutely fails to respond

so i am making this game for iOS, and in it I display pictures on the screen,

in landscape mode i want them to look like this

X X X

in portrait i want them to look like this

X

X

X

i realized that since the player would be rotating their device the objects wouldn't even need to move! (YAY) all i needed to do was to rotate them so they remain facing the same way each time.

so i am trying to make the objects rotate to fit each orientation

but for some reason, when i open the game in my Xcode iOS simulator, there are no effects. none, zilch. what do you think is going on?

heres the code, it is attached to my three game objects

     if(Screen.orientation == ScreenOrientation.LandscapeRight){
         Destroy(gameObject);
         transform.rotation.eulerAngles = Vector3(0,0,90);
     
     }
     if(Screen.orientation == ScreenOrientation.PortraitUpsideDown){
         transform.rotation.eulerAngles = Vector3(0,0,180);
     
     }
     if(Screen.orientation == ScreenOrientation.LandscapeLeft){
     
         transform.rotation.eulerAngles = Vector3(0,0,270);
     
     }
     if(Screen.orientation == ScreenOrientation.Portrait){
     
         transform.rotation.eulerAngles = Vector3(0,0,0);
     
     }        

thanks for all help!

Comment
Add comment · Show 3
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 Joyrider · May 16, 2014 at 07:03 AM 1
Share

Are you changing your Screen.orientation value somewhere?

Because (unless maybe ScreenOrientation.AutoRotate is set) it does not so on his own.

You have to check the Input.deviceOrientation (your phone's orientation as detected by the sensors) variable to see which DeviceOrientation state de phone indicates and change the Screen.orientation variable to the corresponding wanted value.

Input.deviceOrientation : indicates how your device is oriented

Screen.orientation : indicates the current orientation used for the GUI (which on its own has no direct link to the device orientation)

avatar image rednax20 · May 18, 2014 at 09:03 PM 0
Share
     if(Input.deviceOrientation == DeviceOrientation.LandscapeRight){

I changed them all to that, they still don't work. i am EXTRE$$anonymous$$ELY confused i get this error message

Operator '==' cannot be used with a left hand side of type 'UnityEngine.ScreenOrientation' and a right hand side of type 'UnityEngine.DeviceOrientation'.

avatar image rednax20 · May 19, 2014 at 07:26 PM 0
Share

okay, freaky, i copied the example code from the documentation, and pasted it into my code. now it works. I checked and re-re-rechecked what i had typed and what the documentation said. It is exactly the same!!!!!!!

well it works now, but do you think it was something else in the code that threw it off, or is this a bug i should report to unity?

i mean what i had before was

 if(Input.deviceOrientation == DeviceOrientation.LandscapeRight){

now i have

 if(Input.deviceOrientation == DeviceOrientation.LandscapeRight){

this seems pretty funky to me

0 Replies

· Add your reply
  • Sort: 

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

iOS - Smooth auto-rotation of orientation 1 Answer

Rotating a gameobject via dragging finger 1 Answer

How do I fix the orientation when game exits and enters the background (iOS)? (Updated) 0 Answers

Transform Rotation - Maths Problem 2 Answers

Gyroscope Tilting Rotation. Quaternions T_T Help. 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