Project_WL/Assets/Script/Util/UISafeAreaRightController.cs

32 lines
850 B
C#

using UnityEngine;
public class UISafeAreaRightController : MyCoroutine
{
public bool BasePosisLeft;
public float xMul = 1f;
private UIRoot m_cUIRoot = null;
private float Ori_x = 0f;
void Awake()
{
if (null == m_cUIRoot)
m_cUIRoot = GetComponentInParent<UIRoot>();
Ori_x = transform.localPosition.x;
Set_Repeat_for1sec(ComputeSafeAreaOffest);
}
private void Start()
{
ComputeSafeAreaOffest();
}
void ComputeSafeAreaOffest()
{
if (BasePosisLeft)
transform.localPosition = new Vector3(Ori_x + Screen.safeArea.y * xMul, transform.localPosition.y, transform.localPosition.z);
else
transform.localPosition = new Vector3(Ori_x - Screen.safeArea.y * xMul, transform.localPosition.y, transform.localPosition.z);
}
}