This commit is contained in:
SoulliesOfficial
2025-10-23 00:49:44 -04:00
parent 9b1b5ca93f
commit 61a397dd4c
9846 changed files with 2618439 additions and 793547 deletions

View File

@@ -0,0 +1,15 @@
using System;
using UnityEngine;
namespace Continentis
{
public abstract class UIElementBase : MonoBehaviour
{
public RectTransform rectTransform;
protected virtual void Awake()
{
rectTransform ??= GetComponent<RectTransform>();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 71ebe269450f5dd46996e789ea821f9e

View File

@@ -0,0 +1,37 @@
using System.Collections.Generic;
using SLSFramework.General;
using UnityEngine;
namespace Continentis
{
public abstract partial class UIManagerBase : Singleton<UIManagerBase>
{
[Header("UI Prefabs")]
public Dictionary<string, GameObject> uiElementPrefabs = new Dictionary<string, GameObject>();
public Dictionary<string, GameObject> uiPagePrefabs = new Dictionary<string, GameObject>();
[Header("Pages")]
public List<UIPageBase> uiPageList = new List<UIPageBase>(); // 用于管理UI堆栈
[Header("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;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 263bd9d6ba87e1542b8fdf608cc1e6e1

View File

@@ -0,0 +1,36 @@
using UnityEngine;
namespace Continentis
{
public abstract class UIPageBase : UIElementBase
{
public UIManagerBase uiManager;
public CanvasGroup canvasGroup;
protected override void Awake()
{
base.Awake();
Initialize(transform.parent.GetComponent<UIManagerBase>());
}
public virtual void Initialize(UIManagerBase sourceManager)
{
if (sourceManager != null)
{
this.uiManager ??= sourceManager;
}
}
public virtual void Show()
{
uiManager.uiPageList.Add(this);
gameObject.SetActive(true);
}
public virtual void Close()
{
uiManager.uiPageList.Remove(this);
gameObject.SetActive(false);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cc4ec09be17fda745b0a5af6ec675912

View File

@@ -0,0 +1,36 @@
using System;
using UniRx;
using UnityEngine;
namespace Continentis
{
public class WaitableUIElement : UIElementBase
{
/// <summary>
/// 显示该UI面板。
/// </summary>
public virtual void Show()
{
gameObject.SetActive(true);
}
/// <summary>
/// 隐藏该UI面板。
/// </summary>
public virtual void Hide()
{
gameObject.SetActive(false);
}
/// <summary>
/// 获取一个“确认”事件的 Observable。
/// 这个 Observable 会在玩家做出确认操作(例如点击按钮)时发出一个信号并完成。
/// 指令队列将等待这个 Observable 完成。
/// </summary>
/// <returns>代表确认事件的 Observable 流。</returns>
public virtual IObservable<Unit> OnConfirm()
{
return Observable.ReturnUnit();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 564bf781b725208459f5e2625f975819