更新,spine和很多优化

This commit is contained in:
FloatGaming
2026-02-24 05:36:08 +08:00
parent 14fb281d6f
commit d5c8966abd
2039 changed files with 348643 additions and 2589 deletions
+75 -8
View File
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System;
using System.Collections;
using UnityEngine.SceneManagement;
@@ -72,7 +72,22 @@ public class PauseManager : MonoBehaviour
ResolveOverlayRootForPausePrefab();
EnsureOverlayCanvasGroup();
EnsureOverlayPanelRoot();
SetOverlayVisibleImmediate(false);
// Ensure CanvasGroup is initialized to 0 alpha, but keep interactable/blocksRaycasts true
if (overlayCanvasGroup != null)
{
overlayCanvasGroup.alpha = 0f;
overlayCanvasGroup.interactable = true;
overlayCanvasGroup.blocksRaycasts = true;
}
// Initialize buttons but DO NOT call SetOverlayVisibleImmediate(false) here
// because it would reset the flags we just set.
// Instead, we manually ensure the object is active if that's the desired initial state,
// or just rely on the alpha=0 to hide it.
// Assuming user wants the object active but transparent:
if (overlayRoot != null) overlayRoot.SetActive(true);
TryBindButtons(force: true);
}
@@ -96,9 +111,16 @@ public class PauseManager : MonoBehaviour
if (Input.GetKeyDown(KeyCode.Escape))
{
// User requested ESC as pause trigger in gameplay only.
if (CanPauseFromInput() && !IsPaused)
if (CanPauseFromInput())
{
Pause(true);
if (!IsPaused)
{
Pause(true);
}
else
{
Pause(false);
}
}
}
@@ -118,13 +140,47 @@ public class PauseManager : MonoBehaviour
IsPaused = true;
Time.timeScale = 0f;
OnPauseStateChanged?.Invoke(true);
// Startup flows call Pause(true) before real gameplay starts.
// In that phase we keep time paused but do not show pause UI.
bool allowOverlay = CanPauseFromInput();
// Calculate allowOverlay WITHOUT checking IsPaused (since we just set it to true).
bool allowOverlay = true;
if (onlyInGameplayScene && !IsGameplaySceneActive()) allowOverlay = false;
else if (requirePlaybackStarted)
{
var gm = FindAnyObjectByType<GameManager>();
// If GM missing or playback not started, don't show overlay yet
if (gm != null && !gm.PlaybackStarted) allowOverlay = false;
}
if (allowOverlay)
{
ShowOverlayAnimated(true);
}
else
SetOverlayVisibleImmediate(false);
{
// Startup Pause State:
// Keep object active and blocking raycasts (per user request), but invisible.
if (overlayRoot != null) overlayRoot.SetActive(true);
if (overlayCanvasGroup != null)
{
overlayCanvasGroup.alpha = 0f;
overlayCanvasGroup.interactable = true;
overlayCanvasGroup.blocksRaycasts = true;
}
if (overlayPanelCanvasGroup != null)
{
overlayPanelCanvasGroup.alpha = 0f;
overlayPanelCanvasGroup.interactable = true;
overlayPanelCanvasGroup.blocksRaycasts = true;
}
if (overlayPanelRoot != null)
overlayPanelRoot.localScale = PanelHiddenScale;
}
}
else
{
@@ -186,19 +242,30 @@ public class PauseManager : MonoBehaviour
var gm = FindAnyObjectByType<GameManager>();
if (gm == null) return false;
// If already paused, allow input to unpause regardless of PlaybackStarted state
if (IsPaused) return true;
return gm.PlaybackStarted;
}
private void EnsureOverlayCanvasGroup()
{
if (overlayRoot == null) return;
overlayCanvasGroup = overlayRoot.GetComponent<CanvasGroup>();
if (overlayCanvasGroup == null)
// Priority: Use existing CanvasGroup if available (Index first)
if (!overlayRoot.TryGetComponent(out overlayCanvasGroup))
{
// Fallback: Create only if not found
overlayCanvasGroup = overlayRoot.AddComponent<CanvasGroup>();
}
}
private void ResolveOverlayRootForPausePrefab()
{
// Priority: If manually assigned in Inspector, respect it.
if (overlayRoot != null) return;
if (!preferPausePrefabOverWhiteScreen) return;
// Prefer the real pause prefab root (contains Continue/Replay/Exit).
GameObject pauseRoot = FindPauseMenuRootInScene();