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 lamp · Nov 29, 2013 at 01:53 PM · screenorientationdevice

Orientation Problem

Hello all.

Have been struggling with problems in regards to orientation. In its basic form i have a scene with a cube and box collider. I have a raycast which will tell me weather i have hit the cube object or not and Im using the code below to control the device orientation. Works grand in the player however on device it will only detect touch when the device is either face down or face up. Im assuming that this is because Input.deviceOrientation can return faacedown and faceup which throws off the if statements but i cant for the life of me figure out how to get around it so that it will detect touch when device is faceing side on.

If any of you wonderful people have a solution or a better alternative im all ears.

 void orientation(){
         if(Input.deviceOrientation == DeviceOrientation.LandscapeLeft){
             Screen.orientation = ScreenOrientation.LandscapeLeft;
             currentOrientation = ScreenOrientation.LandscapeLeft;
             landscape = true;
             reposition();
         }
         else if(Input.deviceOrientation == DeviceOrientation.LandscapeRight){
             Screen.orientation = ScreenOrientation.LandscapeRight;
             currentOrientation = ScreenOrientation.LandscapeRight;
             landscape = true;
             reposition();
         }
         else if(Input.deviceOrientation == DeviceOrientation.Portrait){
             Screen.orientation = ScreenOrientation.Portrait;
             currentOrientation = ScreenOrientation.Portrait;
             landscape = false;
             reposition();
         }
         else if(Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown){
             Screen.orientation = ScreenOrientation.PortraitUpsideDown;
             currentOrientation = ScreenOrientation.PortraitUpsideDown;
             landscape = false;
             reposition();    
         }
     }


Additionally

Additionally though iv now encountered a second issue. I am using a similar script to read the last known device orientation (either landscape or portrait) and then set the start of each scene accordingly. This works fine for two scenes but not the third.

Essentially when i load the scene, it gets the last known orientation and calls the above script to sett the screen orientation and reposition all of the gameobjects. It repositions the GameObjects correctly so i know its reading the last orientation, however it does not set the ScreenOrientation. I can find any similar examples other than for older unity versions or windows phone. Developing in unity 4.1 for iPad. Same issue repeats on android however.

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
0

Answer by lamp · Dec 04, 2013 at 09:04 AM

Ok so the first issue i realised it was a foolish mistake on my part. As i had orientation called from FixedUpdate it was repositioning my objects constantly to the same location. Within that i Coroutine disabling the hit until the scene had loaded. So because it was always being called it never had a chance to enable the raycast

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 ashwin12995 · Dec 10, 2015 at 09:12 PM 0
Share

how to set default orientation for each scene?

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

18 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

Related Questions

How to check iOS Device Generation ? 0 Answers

How to allow automatic screen rotation in iOS? 2 Answers

How to test Screen Orientation? 3 Answers

Android Game Orientation cannot be fixed to potrait 0 Answers

Change screen Orientation when change scene 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