多轮审查评估
This commit is contained in:
@@ -13,15 +13,21 @@ namespace BaseGames.UI.Menus
|
||||
/// </summary>
|
||||
public class SaveSlotController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private SaveSlotUI[] _slotUIs; // 3 个存档槽 UI
|
||||
[SerializeField] private SaveSlotUI[] _slotUIs; // 存档槽 UI(数量由 Inspector 决定)
|
||||
[SerializeField] private SaveManager _saveManager;
|
||||
|
||||
[Header("Event Channels")]
|
||||
[SerializeField] private IntEventChannelSO _onSlotConfirmed; // 携带槽索引,供 GameManager 监听
|
||||
|
||||
private async void OnEnable()
|
||||
private void OnEnable()
|
||||
{
|
||||
await RefreshAsync();
|
||||
var task = RefreshAsync();
|
||||
// 捕获 async Task 异常,避免 async void 吞掉未处理异常
|
||||
task.ContinueWith(t =>
|
||||
{
|
||||
if (t.IsFaulted)
|
||||
Debug.LogException(t.Exception?.InnerException ?? t.Exception, this);
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
|
||||
private async Task RefreshAsync()
|
||||
@@ -38,7 +44,7 @@ namespace BaseGames.UI.Menus
|
||||
/// <summary>选中指定槽位(新局或继续)。由 SaveSlotUI 内部按钮调用。</summary>
|
||||
public void OnSlotSelected(int slotIndex)
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= 3 || _saveManager == null) return;
|
||||
if (slotIndex < 0 || slotIndex >= _slotUIs.Length || _saveManager == null) return;
|
||||
_ = SelectSlotAsync(slotIndex);
|
||||
}
|
||||
|
||||
@@ -55,7 +61,7 @@ namespace BaseGames.UI.Menus
|
||||
/// <summary>删除指定槽位存档并刷新 UI。由 SaveSlotUI 内部按钮调用。</summary>
|
||||
public void OnSlotDeleteRequested(int slotIndex)
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= 3 || _saveManager == null) return;
|
||||
if (slotIndex < 0 || slotIndex >= _slotUIs.Length || _saveManager == null) return;
|
||||
_ = DeleteAndRefreshAsync(slotIndex);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user