引入 UISerializationRoot 和 Item

- 完成 MenuForm 和 SelectRoleForm 的迁移
This commit is contained in:
2026-09-13 22:18:29 +08:00
parent e2fdb660ab
commit 091a29db63
101 changed files with 5281 additions and 5753 deletions
@@ -0,0 +1,59 @@
using Cysharp.Threading.Tasks;
using SepCore.AsyncTask;
using SepCore.Event;
using UnityEngine;
using UnityEngine.UI;
namespace SepCore.UI
{
public class RoleItem : MonoBehaviour
{
[SerializeField] private Image _roleImage = null;
private RoleItemContext _context = null;
private bool _listenersBound;
public async UniTaskVoid OnInit(RoleItemContext context)
{
EnsureListeners();
_context = context;
if (string.IsNullOrEmpty(_context.IconName))
{
return;
}
_roleImage.sprite = await SpriteLoader.LoadSpriteByKeyAsync(_context.IconName);
}
public void OnReset()
{
_context = null;
}
private void EnsureListeners()
{
if (_listenersBound)
{
return;
}
_listenersBound = true;
CommonButton button = GetComponent<CommonButton>();
button.onClick.AddListener(OnConfirmRoleClick);
button.RegisterPointerEnterAction(OnHoverEnter);
}
private void OnHoverEnter()
{
GameEntry.Event.Fire(this, SelectRoleHoverEventArgs.Create(_context.RoleName));
}
private void OnConfirmRoleClick()
{
GameEntry.Event.Fire(this, SelectRoleConfirmEventArgs.Create());
}
}
}