using System.Collections; using System.Collections.Generic; using UnityEngine; public class SafeArea : MonoBehaviour { public bool BaseIsLeft = true; public float OffSet = 0f; ScreenOrientation screenOrientation = ScreenOrientation.Portrait; IEnumerator Start() { var rect = GetComponent(); var originalPos = rect.anchoredPosition; float Gap = Screen.height - Screen.safeArea.height; while (true) { switch (Screen.orientation) { case ScreenOrientation.LandscapeLeft: // 노치가 왼쪽 if (screenOrientation != Screen.orientation) { screenOrientation = Screen.orientation; if (BaseIsLeft) rect.anchoredPosition = new Vector2(originalPos.x + OffSet + Gap, originalPos.y); } break; case ScreenOrientation.LandscapeRight: if (screenOrientation != Screen.orientation) { screenOrientation = Screen.orientation; rect.anchoredPosition = originalPos; } break; } yield return null; } } }