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 hyliandanny · Apr 29, 2013 at 06:54 PM · iossdkorientationlandscapeportrait

How can I limit my app to specific orientations?

There are questions around here about how to check what orientation is currently in effect, but I'm having trouble controlling the orientation.

In my case, my app is doing funny things by rotating in all portrait and landscape modes when the device is turned. In the XCode build, I've been going through AppController .mm and tweaking multiple settings around portrait mode. Nothing has worked to limit the app to landscape modes only.

How can I limit my app to landscape modes only?

This behavior happens when I add my own SDK to the app. Without my SDK, the app only respects landscape modes.

I would have thought that changing code at the AppController. mm level would be the end-all, even despite settings in my SDK. I'm asking here, now, to understand why I can't override the orientation settings in code. Ideas?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Apr 29, 2013 at 07:38 PM

Either:

  • Resolution And Presentation

  • or via scripting

edit ps. there's another way:

  • top secret

;)

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 hyliandanny · Apr 29, 2013 at 07:49 PM 0
Share

Oh, silly Bunny.

The build settings work fine (as listed in your first suggestion) as long as my SD$$anonymous$$ isn't used. In that case, orientation mania ensues!

I'll try manually scripting in orientation limitations, but is this somehow better than setting the Build Player Settings options? Why would one work but not the other?

As for your top secret route, the second result is actually what made me think I could change the objective-C AppController .mm methods to get the desired result. It still doesn't work! I'd love your thoughts on how these components -- scripted UI settings vs. Build Player Settings vs. objective-C code -- interact, even if it's just a general overview!

Alternately, feel free to provide the top secret search query that'll yield such an overview. ;)

avatar image Bunny83 · Apr 29, 2013 at 09:15 PM 0
Share

Silly?... ok...

Those are the only two ways to limit the rotation in Unity. When you do some magic stuff in xcode that's not related to Unity at all.

You ask why your SD$$anonymous$$ (whatever that might be) changes the autorotation behaviour / settings? Well, let me ask this to you since it's your SD$$anonymous$$, isn't it?

I ask myself what kind of answer do you expect? It seems you use some custom native code which you probably added after the Unity build and manually changed "some" xcode settings.

$$anonymous$$aybe you should read your question again and think about what kind of information you're searching for, because at the moment this is a question like "I've done something and now something else didn't work the way i want".

Sorry if that sounds a bit harsh but, seriously, what do you expect?

avatar image hyliandanny · Apr 29, 2013 at 09:26 PM 0
Share

That's actually great information! Thanks for the discussion as you've now pointed out new information.

only two ways

It seems you use some custom native code which you probably added after the Unity build and manually changed "some" xcode settings.

The abstractions must be so natural to you that you think it sounds harsh to point out the general way they all connect. Since my SD$$anonymous$$ is set from a Unity package, the objective-C code itself is different than the typical generation. If there are only two ways to change the rotation, then I'll continue the search for where those two ways manifest in the generated objective-C code -- though UA is made all the better for experts like you that can lead future users there more efficiently, so thanks!

The reason my SD$$anonymous$$ is confusing me is because it would seem like the AppController code would be the ultimate decider for orientation. After all, it contains orientation callbacks such as the one mentioned in the 2nd Google result from your original top secret query. ;)

But since my SD$$anonymous$$ is generated from an imported Unity package, then that AppController code should still be as Unity expects and generates. Whether or not my SD$$anonymous$$ is the final call on orientation, or whether it's the AppController generated by Unity, is something you've helped narrow down to 2 sources within Unity.

Thank you! $$anonymous$$eep up the harshness, I guess. Someday, users like you will make UA helpful again if you keep it up. :)

avatar image hyliandanny · Apr 29, 2013 at 09:36 PM 0
Share

P.S. Scripting it in as you suggested in option #2 does not affect landscape mode. This leads me to believe that somehow, execution of settings is first based on Unity settings/scripts and THEN overwritten by SD$$anonymous$$s used.

avatar image Bunny83 · Apr 30, 2013 at 07:42 AM 0
Share

Of course changing the setting via scripting will only allow you to change the settings when the first frame is executed. Before that only the presentation settings are valid.

It seems you dig quite deep into native code, good luck ;)

Show more comments
avatar image
0

Answer by hyliandanny · May 02, 2013 at 07:01 PM

Lots of information toward an answer has been discovered through a discussion at Reddit.

http://stackoverflow.com/questions/16286894/how-does-my-ios-sdk-affect-the-orientation-settings-in-unity/16345746#16345746

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

15 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

Related Questions

Is is possible for Unity 3D smartphone app to support multiple orientations 1 Answer

iOS8 Screen Orientation Bug?? 0 Answers

iOS orientation problem 1 Answer

Why do I get lower framerate in Portrait than I do in Landscape? Can I fix this? 1 Answer

How can the iPad keyboard be properly landscaped? It always defaults to portrait 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