using System; using UnityEngine; public class UI_ScreenFitPos : UI_ScreenFitBase { protected override void Start() { base.Start(); } protected override void Update() { base.Update(); } protected override void FitAction() { Vector3 zero = Vector3.zero; if (this.m_UIFitType == UI_ScreenFitPos.FitType.HorizontalLeft) { zero.x = 0f; } else if (this.m_UIFitType == UI_ScreenFitPos.FitType.HorizontalRight) { zero.x = (float)Screen.width; } else if (this.m_UIFitType == UI_ScreenFitPos.FitType.VerticalBottom) { zero.y = 0f; } else if (this.m_UIFitType == UI_ScreenFitPos.FitType.VerticalTop) { zero.y = (float)Screen.height; } Vector3 vector = UI_ScreenFitBase.PointToScreenPos(zero); if (this.m_UIFitType == UI_ScreenFitPos.FitType.HorizontalLeft || this.m_UIFitType == UI_ScreenFitPos.FitType.HorizontalRight) { base.transform.localPosition = new Vector3(vector.x, base.transform.localPosition.y, 0f); } else { base.transform.localPosition = new Vector3(base.transform.localPosition.x, vector.y, 0f); } } [SerializeField] private UI_ScreenFitPos.FitType m_UIFitType = UI_ScreenFitPos.FitType.HorizontalLeft; private enum FitType { HorizontalRight, HorizontalLeft, VerticalTop, VerticalBottom } }