summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-04-23 13:24:05 +0800
committerchai <chaifix@163.com>2022-04-23 13:24:05 +0800
commitbdb737230b30e8fb9be63d95b792e8c8ba531ea0 (patch)
tree9e1fe83c65af581d6b3411bcf1b00af4bde8990a /SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs
parent747a355b8a7d273264ce1d8f1848633f8fa52c47 (diff)
* ui staff
Diffstat (limited to 'SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs')
-rw-r--r--SurvivalTest/Assets/Scripts/UI/Panel/PanelBase.cs35
1 files changed, 25 insertions, 10 deletions
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<RectTransform>();
+ 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