38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using SoulliesFramework.General;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis
|
|
{
|
|
public abstract partial class UIManagerBase : Singleton<UIManagerBase>
|
|
{
|
|
[Title("UI Prefabs")]
|
|
public Dictionary<string, GameObject> uiElementPrefabs = new Dictionary<string, GameObject>();
|
|
public Dictionary<string, GameObject> uiPagePrefabs = new Dictionary<string, GameObject>();
|
|
|
|
[Title("Pages")]
|
|
public List<UIPageBase> uiPageList = new List<UIPageBase>(); // 用于管理UI堆栈
|
|
|
|
[Title("Canvas")]
|
|
public Canvas mainCanvas;
|
|
public RectTransform canvasTransform;
|
|
}
|
|
|
|
public partial class UIManagerBase
|
|
{
|
|
public T ShowPage<T>(string pageName) where T : UIPageBase
|
|
{
|
|
GameObject prefab = uiPagePrefabs[pageName];
|
|
GameObject uiInstance = Instantiate(prefab, canvasTransform);
|
|
T page = uiInstance.GetComponent<T>();
|
|
|
|
page.Initialize(this);
|
|
page.Show();
|
|
|
|
// ... 处理层级 ...
|
|
return page;
|
|
}
|
|
|
|
}
|
|
} |