简体   繁体   中英

How does my iOS SDK affect the orientation settings in Unity?

I have a unity app and my own SDK.

  • Without my SDK, the app runs with landscape modes as specified in Unity's Build Player Settings.
  • With my SDK, the app goes into portrait and landscape modes even though only landscape modes are specified in Unity's Build Player Settings.

The generated XCode project has orientation code in its AppController.mm file. Tweaking code there has not restricted the rotation.

How does this happen? Wouldn't the generated XCode project's code -- AppController.mm in particular -- be the ultimate decider for orientation? Does my SDK overwrite all other settings from Unity and even those in the Unity-generated project?

There's a great discussion on this topic at Reddit.

http://www.reddit.com/r/Unity3D/comments/1dghry/adding_an_ios_sdk_through_post_process_build/

Unity ends up completely subverted by Xcode and iOS, including the SDK. What is most interesting is that Unity continues to think it is preserving rotation even when the device has gone into another orientation. This was discovered by putting debug statements showing the orientation of the project: it reported LandscapeRight despite the actual orientation on the device.

This means that the SDK and objective-C code are where orientation adjustments must be made.

How does this happen?

The iOS/XCode code and settings take over. Unity is left in the dark.

Wouldn't the generated Xcode project's code be the ultimate decider for orientation?

Yes and no. The SDK is in conflict with the generated code from Unity, with the SDK winning out. Any changes to decide orientation must be made on the XCode side.

Does my SDK overwrite all other settings from Unity and even those in the Unity-generated project?

Unity continues preserving the settings it can, and -- as far as it knows -- it's doing so correctly. The SDK's setting is what ends up being used in practice, outside the scope of Unity's generated code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM