(client)feat:添加UI管理器,统一管理继承自UIBase的UI并保证显示唯一
This commit is contained in:
@ -5,13 +5,18 @@ using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DevMenuUI : MonoBehaviour
|
||||
public class DevMenuUI : UIBase
|
||||
{
|
||||
public GameObject menuContent;
|
||||
|
||||
public Prefab.TextPrefab textTemplate;
|
||||
public Prefab.ButtonPrefab buttonTemplate;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
actionButton = KeyCode.F1;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Init();
|
||||
@ -19,7 +24,6 @@ namespace UI
|
||||
|
||||
void Init()
|
||||
{
|
||||
Managers.DefineManager.Instance.Init();
|
||||
InitEvent();
|
||||
InitCharacter();
|
||||
}
|
||||
@ -32,6 +36,7 @@ namespace UI
|
||||
// var button= InstantiatePrefab(buttonTemplate, menuContent.transform);
|
||||
// button.text.text = i.ToString();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void InitCharacter()
|
||||
|
15
Client/Assets/Scripts/UI/UIBase.cs
Normal file
15
Client/Assets/Scripts/UI/UIBase.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public abstract class UIBase:MonoBehaviour
|
||||
{
|
||||
public KeyCode actionButton = KeyCode.None;
|
||||
// 显示或隐藏窗口
|
||||
public virtual void Show() { gameObject.SetActive(true); }
|
||||
public virtual void Hide() { gameObject.SetActive(false); }
|
||||
|
||||
// 判断是否可见
|
||||
public bool IsVisible => gameObject.activeInHierarchy;
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/UI/UIBase.cs.meta
Normal file
3
Client/Assets/Scripts/UI/UIBase.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 293a60af40144aafabdf65f49f5c6e44
|
||||
timeCreated: 1752926575
|
Reference in New Issue
Block a user