成就系统 巨大修改 新的ui 黑白效果 等一堆

This commit is contained in:
FloatGaming
2026-01-23 18:43:23 +08:00
parent f3ece026ca
commit 0e47864569
256 changed files with 134131 additions and 31192 deletions
@@ -39,13 +39,17 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
private Transform yellowSpawn;
private Transform purpleSpawn;
private Transform blueSpawn;
// Track last scene to detect scene changes
private int lastSceneIndex = -1;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
// 注意:仅当第一次创建时保留,允许重新加载
// DontDestroyOnLoad(gameObject); // ← 移除此行以允许场景重新加载时的清理
}
else if (Instance != this)
{
@@ -54,29 +58,48 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
}
CacheSpawnPoints();
lastSceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
}
private void Start()
{
// Ensure spawn points are cached after all scene objects are initialized
if (redSpawn == null && redEffect != null)
{
CacheSpawnPoints();
}
CacheSpawnPointsIfNeeded();
}
private void OnEnable()
{
// In case this object survives scene changes / references are assigned late.
if (Instance == null)
{
Instance = this;
}
if (redSpawn == null && redEffect != null)
// Detect scene reload and refresh cache
int currentSceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
if (currentSceneIndex != lastSceneIndex)
{
if (GameConfig.verboseLogs) Debug.Log($"[Animation_Generate] Scene changed detected (from {lastSceneIndex} to {currentSceneIndex}), refreshing spawn point cache");
lastSceneIndex = currentSceneIndex;
CacheSpawnPoints();
}
else
{
CacheSpawnPointsIfNeeded();
}
}
private void CacheSpawnPointsIfNeeded()
{
// Only recache if any of the references appear to be invalid (destroyed)
if (redSpawn == null || greenSpawn == null || yellowSpawn == null || purpleSpawn == null || blueSpawn == null)
{
// Check if the effect GameObjects are still valid
bool anyInvalid = (redEffect == null || redEffect.transform == null) ||
(greenEffect == null || greenEffect.transform == null) ||
(yellowEffect == null || yellowEffect.transform == null) ||
(purpleEffect == null || purpleEffect.transform == null) ||
(blueEffect == null || blueEffect.transform == null);
if (anyInvalid || redSpawn == null)
{
CacheSpawnPoints();
}
}
}
private void CacheSpawnPoints()
@@ -217,12 +240,8 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
{
if (string.IsNullOrEmpty(color)) return null;
// If references were destroyed (Unity fake null) try to rebuild cache once.
if (redSpawn == null && greenSpawn == null && yellowSpawn == null && purpleSpawn == null && blueSpawn == null)
{
if (GameConfig.verboseLogs) Debug.Log("[Animation_Generate] Rebuilding spawn point cache");
CacheSpawnPoints();
}
// 在每次调用时检查是否需要重新缓存
CacheSpawnPointsIfNeeded();
Transform point = null;
switch (color.ToLower())