I need help determining which of these are bugs and should be reported and which are expected behavior.
Using 2019.4.13f1 and targeting iOS
If you build with default orientation LandScapeRight, it will appear in XCode as LandScapeLeft. This hasn’t caused me any real issues until…
When you update your IAP package to 2.1.1 and you have your default orientation set to LandScapeRight, your app will immediately crash on startup. You may also need to have the code ‘Screen.orientation = ScreenOrientation.Landscape;’ in an awake function. I’m not sure if that is related or not to be honest but that did trigger a future crash. The crash you get is:
“Uncaught exception: UIApplicationInvalidInterfaceOrientation: Supported orientations has no common orientation with the application”
That crash is what led me to discover #1 above. That XCode doesn’t match Unity’s build settings. And I went back and looked at builds prior to updating IAP package and they were all like that… they just never crashed until I updated the IAP.
Setting your default orientation to ‘autorotate’ (checking left/right) and then in code calling ‘Screen.orientation = ScreenOrientation.Landscape;’ will result in a crash. This crash is ‘NSInternalInconsistencyException: UnityDefaultViewController should be used only if unity is set to autorotate’. I no longer needed that Screen.orientation code so I just removed it and it avoided the crash. In hindsight, I wonder if this code also led to crash #2.
To me, all 3 of these seem like bugs, but I am not certain. At the very least, it seems they should fail more gracefully than an instant crash.
Luckily I found this thread, generally you’ll want to post in the IAP forum Unity Services - Unity Discussions What iOS version are you using? I will try to reproduce here, we’ve had some reports of rotation issues as you describe
Seems like 1 and 3 above may not be IAP related. Not sure what is expected behavior and what should be reported as bugs, but happy to report a bug on any/all of the above.
To me, it seems like if #1 were fixed then I never would have experienced the rest.
Issue 1 is that when you set LandscapeRight in Unity, it will say LandscapeLeft in XCode. If that were fixed then I probably wouldn’t have crashed. That said, without updating to IAP that issue never caused a crash. It was benign until the IAP sdk was upgraded to the latest.
Again though, I don’t know what is going on under the hood. Seems like there are some bugs here but not certain what is expected and what is not.
I also have the same problem as topic 3.
Set autorotation in Player settings and Landscape Left and Landscape right are checked.
My first code when entering the game is “Screen.orientation = ScreenOrientation.LandscapeLeft;” and it just crashed the game immediately.
Uncaught exception: NSInternalInconsistencyException: UnityDefaultViewController should be used only if unity is set to autorotate
@ickydime I have it added in my project. But I’m a little doubtful that there is a connection. I haven’t read the source code though. I also have the latest Unity IAP installed.
I did some basic checking in code and this is what I found.
UnityViewControllerBase+iOS.mm
- (NSUInteger)supportedInterfaceOrientations
{
NSAssert(UnityShouldAutorotate(), @"UnityDefaultViewController should be used only if unity is set to autorotate");
return EnabledAutorotationInterfaceOrientations();
}```
If I remove the NSAssert the code works as it should. I startup my app and it forces LandscapeLeft for me. After that I can freely rotate in my app.
UnityShouldAutorotate() returns as false. I'm not sure if this is the Player settings Default Orientation value but I guess it is.
![6530366--737558--Current Settings.png|896x282](upload://xvKWkYBT6LmpB1tonfYk7BeavGD.png)
When testing my project in Unity 2018.4.16f1 UnityShouldAutorotate() returns true. But in this project I have an older Unity IAP of 2.0.6 so I don't know if that might be the problem.
I did some more testing.
2018.4.16f1
Unity IAP 1.22.0
UnityShouldAutorotate() = true
Result = No crash
2019.4.14f1
Unity IAP 1.22.0
UnityShouldAutorotate() = false
Result = Crash
2019.4.14f1
Unity IAP 2.1.1
UnityShouldAutorotate() = true
Result = Crash
Updated from 2019.4.6f1 to 2019.4.15f1 and running into the same bug.
Replacing
@implementation UnityDefaultViewController
- (NSUInteger)supportedInterfaceOrientations
{
NSAssert(UnityShouldAutorotate(), @"UnityDefaultViewController should be used only if unity is set to autorotate");
return EnabledAutorotationInterfaceOrientations();
}
Issue 2 is IAP related in that it only happened to me on projects that included IAP. Issue 1 and issue 3 are not IAP related though all 3 issues tie together since without #1 you probably wouldn’t experience #2.
I realized you are only interested in the IAP related issues, but wouldn’t someone else on your team be interested in any of the bugs. Looks like everyone on this thread has found a work-around so we aren’t waiting for a fix, just trying to help you address it for others as the instant crashes are a pain to debug.
@JeffDUnity3D any update on this? I’m experiencing something very similar. Just setting the Screen.orientation in an Awake method of a script when booting the game. Game is built with autorotation on and LandscapeLeft and LandscapeRight. I’m on 2020.3.12f1.
@JeffDUnity3D yeah the issue tracker mentions it looks to be fixed in Unity 2021 but it seems that people here and in other forum posts are recently still reproducing it on 2019.4.x and 2020.3.x so maybe it should have been back-ported to the LTS versions. Is there any way to check if this issue was back-ported and if not if someone can reproduce it on some of the Unity versions we mentioned? Otherwise I should blindly try to update from 2020.3.12f1 to the latest LTS and see if somehow the fix slipped in, I couldn’t see anything related in the release notes following the LTS version I use.