33 lines
898 B
C#
33 lines
898 B
C#
using UnityEngine;
|
|
|
|
public class UIBase : MonoBehaviour
|
|
{
|
|
public RectTransform rectTransform;
|
|
public UIBase parent;
|
|
public virtual void OnCreate()
|
|
{
|
|
rectTransform = GetComponent<RectTransform>();
|
|
}
|
|
public virtual void OnShow() { }
|
|
public virtual void OnHide() { }
|
|
|
|
public void SetFull()
|
|
{
|
|
rectTransform.anchorMin = Vector2.zero;
|
|
rectTransform.anchorMax = Vector2.one;
|
|
rectTransform.offsetMin = Vector2.zero;
|
|
rectTransform.offsetMax = Vector2.zero;
|
|
rectTransform.sizeDelta = Vector2.zero;
|
|
}
|
|
|
|
public void SetParent(RectTransform ui, bool isFull = false)
|
|
{
|
|
rectTransform.SetParent(ui);
|
|
rectTransform.localScale = Vector3.one;
|
|
rectTransform.localPosition = Vector3.zero;
|
|
rectTransform.localRotation = Quaternion.identity;
|
|
if (isFull)
|
|
SetFull();
|
|
}
|
|
}
|