- Home /
How do I fix the orientation when game exits and enters the background (iOS)? (Updated)
Game I wrote is limited to Autorotate in Landscape only (through Unity Player Settings - Unity 4.6.2). After successful build in XCode 6.1.1 (testing on iPhone 5), the game plays correctly in correct orientation. Problem occurs when game is exited and enters the background. The orientation changes to Portrait-UpsideDown. Is there a Unity setting I'm missing? How can I fix this? I've searched on the Unity Forum, Stackoverflow and many other game forums but I can't find anything remotely close to this problem. Anyone ever have this problem? How did you solve it? Thanks...
Edit: I narrowed the problem to the iAds code taken from the Unity docs (http://docs.unity3d.com/ScriptReference/ADBannerView.html). First I created an empty splash screen with just an image on it. I did a build through Unity(4.6.2), compiled it in Xcode (6.1.1) and loaded it on my iPhone 5 (iOS 8.1.3). The screen orientations were correct and when it entered the background, the orientation was correct (LandscapeLeft). Afterwards, I added an empty game object with just the iADs code to it. I built it, compiled it and loaded it to my iPhone. The orientation upon applicationDidEnterBackground was rotated to the left, thereby making it look like it was upside down. I repeated both tests several times to make sure it wasn't just a fluke, but the results were the same each time (correct exit rotation without the iAds code, incorrect with iAds included). Is this a bug with UNITY or with Xcode? Below is my code for the iADs. Any thoughts?
using UnityEngine;
using System.Collections;
public class iAds : MonoBehaviour {
public ADBannerView banner = null;
void Start()
{
banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Bottom);
ADBannerView.onBannerWasClicked += OnBannerClicked;
ADBannerView.onBannerWasLoaded += OnBannerLoaded;
}
void OnBannerClicked()
{
Debug.Log("Clicked!\n");
}
void OnBannerLoaded()
{
banner.visible = true;
}
}
hi i am also facing the same issue. did you find any fix for this problem?
No, I was not able to find a fix for this problem. I submitted a bug report to Unity but they never replied. I ended up removing the iAds code and used Admob coding ins$$anonymous$$d.
Experiencing the same trouble. Not quite willing to abandon iAds... Are there any updates on this issue?
@celestis - Sorry, I completely removed the iAds code from my game because of this issue. No one from Unity ever replied to my bug report. I moved over to Admob codes in my game.
I see. Well, that's sad, thanks for reply anyway. I made a sort of workaround: in OnApplicationPause I show a premade overlay with a pause sign. This helps a bit, at least the app doesn't look that ugly now.