61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class OrientationChecker : MonoBehaviour
|
|
{
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
void OnEnable() {
|
|
|
|
if(Screen.orientation == ScreenOrientation.Portrait)
|
|
{
|
|
this.gameObject.transform.GetChild(0).gameObject.SetActive(true);
|
|
}
|
|
if(Screen.orientation == ScreenOrientation.PortraitUpsideDown)
|
|
{
|
|
this.gameObject.transform.GetChild(0).gameObject.SetActive(true);
|
|
}
|
|
|
|
if(Screen.orientation == ScreenOrientation.LandscapeLeft)
|
|
{
|
|
this.gameObject.transform.GetChild(1).gameObject.SetActive(true);
|
|
}
|
|
if(Screen.orientation == ScreenOrientation.LandscapeRight)
|
|
{
|
|
this.gameObject.transform.GetChild(1).gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
void OnDisable() {
|
|
|
|
if(Screen.orientation == ScreenOrientation.Portrait)
|
|
{
|
|
this.gameObject.transform.GetChild(0).gameObject.SetActive(false);
|
|
}
|
|
if(Screen.orientation == ScreenOrientation.PortraitUpsideDown)
|
|
{
|
|
this.gameObject.transform.GetChild(0).gameObject.SetActive(false);
|
|
}
|
|
|
|
if(Screen.orientation == ScreenOrientation.LandscapeLeft)
|
|
{
|
|
this.gameObject.transform.GetChild(1).gameObject.SetActive(false);
|
|
}
|
|
if(Screen.orientation == ScreenOrientation.LandscapeRight)
|
|
{
|
|
this.gameObject.transform.GetChild(1).gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|