From bdb737230b30e8fb9be63d95b792e8c8ba531ea0 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 23 Apr 2022 13:24:05 +0800 Subject: * ui staff --- SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs | 35 ++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs') diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs index 3081d97..9d1157c 100644 --- a/SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs @@ -2,26 +2,41 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] [DisallowMultipleComponent] -public class PanelBase : MonoBehaviour +public abstract class PanelBase : MonoBehaviour { - public virtual void Set(object param) + public abstract void Set(object param); + + public virtual void OnEnable() { + InitRectTransform(); } - void Start() - { - - } + public void InitRectTransform() + { + RectTransform rect = gameObject.GetComponent(); + rect.anchorMin = new Vector2(0, 0); + rect.anchorMax = new Vector2(1, 1); + + rect.localScale = new Vector3(1, 1, 1); + + rect.anchoredPosition3D = Vector3.zero; + + rect.offsetMin = new Vector2(0, 0); + rect.offsetMax = new Vector2(0, 0); - protected virtual void Update() - { - } + rect.pivot = new Vector2(0.5f, 0.5f); + } + + protected virtual void Update() + { + } protected virtual void OnSecondUpdate() { } -} +} \ No newline at end of file -- cgit v1.1-26-g67d0