- Home /
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?
Answer by Bunny83 · Apr 29, 2013 at 07:38 PM
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. ;)
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?
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. :)
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.
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 ;)
Answer by hyliandanny · May 02, 2013 at 07:01 PM
Lots of information toward an answer has been discovered through a discussion at Reddit.
Your answer
Follow this Question
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