This commit is contained in:
2025-11-12 07:04:31 +08:00
parent 33a4742904
commit f615d8ddb0
68 changed files with 1388 additions and 1478 deletions

View File

@@ -1,38 +1,41 @@
using UnityEngine;
public class UIBase : MonoBehaviour
namespace Tuan.GameScripts.Main
{
public RectTransform rectTransform
public class UIBase : MonoBehaviour
{
get
public RectTransform rectTransform
{
if (_rectTransform == null)
_rectTransform = GetComponent<RectTransform>();
return _rectTransform;
get
{
if (_rectTransform == null)
_rectTransform = GetComponent<RectTransform>();
return _rectTransform;
}
}
RectTransform _rectTransform;
public UIBase parent;
public virtual void OnCreate() { }
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();
}
}
RectTransform _rectTransform;
public UIBase parent;
public virtual void OnCreate() { }
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();
}
}