更新
This commit is contained in:
57
Assets/Scripts/Menu/ConfirmOverrideRunPanel.cs
Normal file
57
Assets/Scripts/Menu/ConfirmOverrideRunPanel.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using Continentis.MainGame;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Continentis.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// 覆盖跑局确认面板。
|
||||
/// 挂载在确认面板的根 GameObject 上,自行管理显示/隐藏和按钮事件。
|
||||
/// 由 MenuManager 通过 Show(onConfirm) 唤起;确认后先删除旧跑局存档,再执行回调。
|
||||
/// </summary>
|
||||
public class ConfirmOverrideRunPanel : MonoBehaviour
|
||||
{
|
||||
public Button confirmButton;
|
||||
public Button cancelButton;
|
||||
|
||||
private Action _onConfirm;
|
||||
|
||||
// ── 生命周期 ──────────────────────────────────────────────────────
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
confirmButton.onClick.AddListener(OnConfirm);
|
||||
cancelButton.onClick.AddListener(OnCancel);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// ── 公共 API ──────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// 显示确认面板。
|
||||
/// </summary>
|
||||
/// <param name="onConfirm">玩家点击"确认"后执行的回调(由 MenuManager 传入 StartNewRun)。</param>
|
||||
public void Show(Action onConfirm)
|
||||
{
|
||||
_onConfirm = onConfirm;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// ── 按钮事件 ──────────────────────────────────────────────────────
|
||||
|
||||
private void OnConfirm()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
SaveManager.Instance.DeleteRunSave();
|
||||
_onConfirm?.Invoke();
|
||||
_onConfirm = null;
|
||||
}
|
||||
|
||||
private void OnCancel()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
_onConfirm = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user