From 0a885e25144ca9d023869b4ce01be53e83e740c3 Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Tue, 17 Dec 2024 18:03:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E7=AA=97=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meng_yao/Assets/script/A_Fight/Manager.cs | 53 +++++++++++++++++++ .../Assets/script/A_Fight/Manager.cs.meta | 11 ++++ 2 files changed, 64 insertions(+) create mode 100644 meng_yao/Assets/script/A_Fight/Manager.cs create mode 100644 meng_yao/Assets/script/A_Fight/Manager.cs.meta diff --git a/meng_yao/Assets/script/A_Fight/Manager.cs b/meng_yao/Assets/script/A_Fight/Manager.cs new file mode 100644 index 000000000..de944b296 --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/Manager.cs @@ -0,0 +1,53 @@ +using DG.Tweening; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UIElements; + +public class Manager : MonoBehaviour +{ + public static Manager instance; + public Canvas _Canvas; + public List panelsPrefab = new List(); + + // 使用Dictionary来管理已实例化的面板,键为预制体的索引,值为实例化的面板 + private Dictionary panels = new Dictionary(); + + void Awake() + { + instance = this; + } + + public GameObject ShowPanel(int index) + { + if (index < 0 || index >= panelsPrefab.Count) + { + Debug.LogError("ShowPanel: Index 超出范围"); + return null; + } + if (panels.ContainsKey(index)) + { + ShowPanel(panels[index]); + return panels[index]; + } + else + { + ShowPanel(panels[index]); + return GameObject.Instantiate(panelsPrefab[index], _Canvas.transform); + } + + return null; + } + + + public virtual void ShowPanel(GameObject _panel) + { + _panel.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); + _panel.transform.DOScale(1f, 0.5f); + } + + public virtual void hidePanel(GameObject _panel) + { + _panel.SetActive(false); + } +} diff --git a/meng_yao/Assets/script/A_Fight/Manager.cs.meta b/meng_yao/Assets/script/A_Fight/Manager.cs.meta new file mode 100644 index 000000000..dcb103811 --- /dev/null +++ b/meng_yao/Assets/script/A_Fight/Manager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 540b624a12d7f6b41aa484eb3aaf4aea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: