Orientation not adjusting game pad properly
I am having an issue with orientation for Android. The game pad in the game I'm developing loads small in Unity during the game mode.
I have a script for Landscape and Portrait views to orientate the game for android and other mobile devices.
I have included 2 images of the landscape view as the pad is small on load, but when I change from landscape to portrait and back to landscape, the pad gets larger to the size that is preset for the game settings.
My script as c# is as follows:
using UnityEngine; using System.Collections;
public class ScreenOrientationMask : MonoBehaviour {
public ScreenOrientation screenOrientation;
void Awake() {
UIAssistant.onScreenResize += UpdateContent;
}
void OnEnable () {
UpdateContent();
}
void UpdateContent () {
bool landscape = Screen.width > Screen.height;
bool visible = (screenOrientation == ScreenOrientation.Portrait && !landscape) || (screenOrientation == ScreenOrientation.Landscape && landscape);
foreach (Transform child in transform)
child.gameObject.SetActive(visible);
if (gameObject != null){
}
}
public enum ScreenOrientation
{
Portrait, Landscape
};
}
Your answer
Follow this Question
Related Questions
Android app unity not working 0 Answers
is there a way to save data on Android before quit? 1 Answer
How to use the GPGS ISavedGameMetadata? 1 Answer
Smooth acceleration 0 Answers
How to make platform to rotate player ? 0 Answers