using System.Collections; using System.Collections.Generic; using UnityEngine; public class UISafeAreaTopController : MonoBehaviour { private UIRoot m_cUIRoot = null; private float Ori_y = 0f; void Awake() { if (null == m_cUIRoot) m_cUIRoot = GetComponentInParent(); Ori_y = transform.localPosition.y; } private void Start() { ComputeSafeAreaOffest(); } void ComputeSafeAreaOffest() { // SafeArea 비율 float safeY = Screen.safeArea.y / Screen.height; float safeH = Screen.safeArea.height / Screen.height; if (null == m_cUIRoot) return; // safeY : Y Bottom Offset 값 float fOffsetY_Bottom = safeY * m_cUIRoot.manualHeight; float fOffsetY_Top = fOffsetY_Bottom + (safeH * m_cUIRoot.manualHeight) - m_cUIRoot.manualHeight; transform.localPosition = new Vector3(transform.localPosition.x, fOffsetY_Top + Ori_y, transform.localPosition.z); } }