技能主要更新,修复卡顿并加入动画,以及各种其他更新。

This commit is contained in:
2026-02-07 21:05:17 +08:00
parent abeca51be5
commit 1ac3cd0104
1349 changed files with 1526749 additions and 24850 deletions
+190 -70
View File
@@ -3,12 +3,13 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
using DG.Tweening;
public class selected_songInfo : MonoBehaviour
{
public Image t_songCoverImage;
public Image btm_songCoverImage;
[Header("极简信息")]
[Header("Ϣ")]
public Text songNameText;
public Text currentDifficulty;
public Text sumScore_thisDifficulty;
@@ -17,22 +18,22 @@ public class selected_songInfo : MonoBehaviour
public Image c_DifficultyImage;
public Image c_imageMask;
[Header("分级颜色")]
[Header("ּɫ")]
public Color _0to5d5;
public Color _5d5to11;
public Color _11to16d5;
public Color _16d5to22;
public Color _equal22;
[Header("对应的难度按钮")]
[Header("ӦѶȰť")]
public List<Button> difficultyButtons = new List<Button>();
[Header("对应的难度文本")]
[Header("ӦѶı")]
public List<Text> difficultyTexts = new List<Text>();
[Header("enter detail page")]
public Button enterDetailPageButton;
[Header("quick enter game play")]
public Button quickEnter_gamePlay;
[Header("指定image背景色")]
[Header("ָimageɫ")]
public Sprite buttons_bgImage;
[Header("black mask")]
public Image blackMaskImage;
@@ -40,41 +41,63 @@ public class selected_songInfo : MonoBehaviour
// store the original sprites so we don't overwrite the designer's setup
private List<Sprite> originalButtonSprites = new List<Sprite>();
[Header("Switch Animations")]
[SerializeField] bool play_SongSwitch_Anim = true;
[SerializeField] RectTransform songInfo_Root;
[SerializeField] float songSwitch_Time = 0.22f;
[SerializeField] float songSwitch_Move = 30f;
[SerializeField] Ease songSwitch_Ease = Ease.OutCubic;
[SerializeField] bool play_DifficultySwitch_Anim = true;
[SerializeField] float diffSwitch_Punch = 0.06f;
[SerializeField] float diffSwitch_Punch_Time = 0.18f;
[SerializeField] float diffSwitch_Text_Fade = 0.08f;
[SerializeField] bool switch_Use_Unscaled = true;
private CanvasGroup songInfo_Canvas;
private Vector2 songInfo_BasePos;
private bool songInfo_BaseCached;
private int lastSongId = -1;
private static void LogVerbose(string message)
{
if (GameConfig.verboseLogs) Debug.LogWarning(message);
}
void Awake()
{
Debug.LogWarning("selected_songInfo.Awake called");
LogVerbose("selected_songInfo.Awake called");
}
void OnEnable()
{
Debug.LogWarning("selected_songInfo.OnEnable called");
LogVerbose("selected_songInfo.OnEnable called");
// register listeners here to ensure binding even if Start wasn't called yet
if (enterDetailPageButton != null)
{
enterDetailPageButton.onClick.RemoveListener(OnEnterDetailPageClicked);
enterDetailPageButton.onClick.AddListener(OnEnterDetailPageClicked);
Debug.LogWarning("enterDetailPageButton listener added");
LogVerbose("enterDetailPageButton listener added");
}
else
{
Debug.LogWarning("enterDetailPageButton is null in OnEnable");
LogVerbose("enterDetailPageButton is null in OnEnable");
}
if (quickEnter_gamePlay != null)
{
quickEnter_gamePlay.onClick.RemoveListener(OnQuickEnterClicked);
quickEnter_gamePlay.onClick.AddListener(OnQuickEnterClicked);
Debug.LogWarning("quickEnter_gamePlay listener added");
LogVerbose("quickEnter_gamePlay listener added");
}
else
{
Debug.LogWarning("quickEnter_gamePlay is null in OnEnable");
LogVerbose("quickEnter_gamePlay is null in OnEnable");
}
}
void OnDisable()
{
Debug.LogWarning("selected_songInfo.OnDisable called");
LogVerbose("selected_songInfo.OnDisable called");
if (enterDetailPageButton != null)
{
enterDetailPageButton.onClick.RemoveListener(OnEnterDetailPageClicked);
@@ -87,14 +110,14 @@ public class selected_songInfo : MonoBehaviour
void OnDestroy()
{
Debug.LogWarning("selected_songInfo.OnDestroy called");
LogVerbose("selected_songInfo.OnDestroy called");
// ensure we remove sceneLoaded subscription if still present
SceneManager.sceneLoaded -= OnSceneLoadedAfterQuickEnter;
}
void Start()
{
Debug.LogWarning("selected_songInfo.Start called");
LogVerbose("selected_songInfo.Start called");
// ensure black mask is transparent and inactive at start
if (blackMaskImage != null)
@@ -137,8 +160,8 @@ public class selected_songInfo : MonoBehaviour
UpdateSelectedSongDisplay();
// Diagnostic: confirm Start ran and key refs
Debug.LogWarning($"selected_songInfo.Start: quickEnter_gamePlay is {(quickEnter_gamePlay == null ? "NULL" : "ASSIGNED")}, enterDetail assigned={(enterDetailPageButton == null ? "NULL" : "ASSIGNED")}, blackMask assigned={(blackMaskImage == null ? "NULL" : "ASSIGNED")}");
Debug.LogWarning($"selected_songInfo.Start: SongDataHolder.SelectedSongData is {(SongDataHolder.SelectedSongData == null ? "NULL" : SongDataHolder.SelectedSongData.songName)}");
LogVerbose($"selected_songInfo.Start: quickEnter_gamePlay is {(quickEnter_gamePlay == null ? "NULL" : "ASSIGNED")}, enterDetail assigned={(enterDetailPageButton == null ? "NULL" : "ASSIGNED")}, blackMask assigned={(blackMaskImage == null ? "NULL" : "ASSIGNED")}");
LogVerbose($"selected_songInfo.Start: SongDataHolder.SelectedSongData is {(SongDataHolder.SelectedSongData == null ? "NULL" : SongDataHolder.SelectedSongData.songName)}");
}
public void UpdateSelectedSongDisplay()
@@ -270,6 +293,8 @@ public class selected_songInfo : MonoBehaviour
int enterTimes = song.game_enterTimes;
total_gameTime.text = enterTimes.ToString();
}
TryPlaySongSwitchAnim(song.songID);
}
else
{
@@ -286,7 +311,7 @@ public class selected_songInfo : MonoBehaviour
}
if (songNameText != null)
{
songNameText.text = "未选择歌曲";
songNameText.text = "δѡ";
}
// restore original difficulty button backgrounds and text colors
@@ -294,6 +319,7 @@ public class selected_songInfo : MonoBehaviour
if (sumScore_thisDifficulty != null) sumScore_thisDifficulty.text = "0";
if (total_gameTime != null) total_gameTime.text = "0";
lastSongId = -1;
}
}
@@ -366,6 +392,7 @@ public class selected_songInfo : MonoBehaviour
// refresh displayed song info so currentDifficulty / difficulty bar update to new difficulty
UpdateSelectedSongDisplay();
PlayDifficultySwitchAnim(index);
}
else
{
@@ -373,11 +400,95 @@ public class selected_songInfo : MonoBehaviour
}
}
private void EnsureSongInfoRoot()
{
if (songInfo_Root == null)
{
songInfo_Root = transform as RectTransform;
}
if (songInfo_Root == null) return;
if (songInfo_Canvas == null || songInfo_Canvas.gameObject != songInfo_Root.gameObject)
{
songInfo_Canvas = songInfo_Root.GetComponent<CanvasGroup>();
if (songInfo_Canvas == null)
{
songInfo_Canvas = songInfo_Root.gameObject.AddComponent<CanvasGroup>();
}
}
}
private void TryPlaySongSwitchAnim(int songId)
{
if (!play_SongSwitch_Anim)
{
lastSongId = songId;
return;
}
if (lastSongId == songId)
{
return;
}
lastSongId = songId;
EnsureSongInfoRoot();
if (songInfo_Root == null || songInfo_Canvas == null)
{
return;
}
songInfo_BasePos = songInfo_Root.anchoredPosition;
songInfo_BaseCached = true;
songInfo_Root.DOKill();
songInfo_Canvas.DOKill();
songInfo_Root.anchoredPosition = songInfo_BasePos + new Vector2(-songSwitch_Move, 0f);
songInfo_Canvas.alpha = 0f;
Sequence seq = DOTween.Sequence().SetUpdate(switch_Use_Unscaled);
seq.Join(songInfo_Root.DOAnchorPos(songInfo_BasePos, songSwitch_Time).SetEase(songSwitch_Ease));
seq.Join(songInfo_Canvas.DOFade(1f, songSwitch_Time));
}
private void PlayDifficultySwitchAnim(int index)
{
if (!play_DifficultySwitch_Anim)
{
return;
}
if (difficultyButtons != null && index >= 0 && index < difficultyButtons.Count)
{
var btn = difficultyButtons[index];
if (btn != null)
{
Transform t = btn.transform;
t.DOKill();
t.localScale = Vector3.one;
t.DOPunchScale(Vector3.one * diffSwitch_Punch, diffSwitch_Punch_Time, 6, 0.7f)
.SetUpdate(switch_Use_Unscaled);
}
}
FlashGraphic(currentDifficulty);
FlashGraphic(sumScore_thisDifficulty);
if (c_DifficultyImage != null)
{
FlashGraphic(c_DifficultyImage);
}
}
private void FlashGraphic(Graphic g)
{
if (g == null) return;
g.DOKill();
Color baseColor = g.color;
float baseAlpha = baseColor.a <= 0f ? 1f : baseColor.a;
baseColor.a = baseAlpha;
g.color = baseColor;
Sequence seq = DOTween.Sequence().SetUpdate(switch_Use_Unscaled);
seq.Append(g.DOFade(Mathf.Clamp01(baseAlpha * 0.35f), diffSwitch_Text_Fade));
seq.Append(g.DOFade(baseAlpha, diffSwitch_Text_Fade));
}
public void OnEnterDetailPageClicked()
{
if (SongDataHolder.SelectedSongData != null)
{
SceneManager.LoadScene("Songs_Select");
StartCoroutine(LoadSceneAsync("Songs_Select"));
}
else
{
@@ -385,6 +496,15 @@ public class selected_songInfo : MonoBehaviour
}
}
private IEnumerator LoadSceneAsync(string sceneName)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName);
while (!asyncLoad.isDone)
{
yield return null;
}
}
private void OnQuickEnterClicked()
{
// use SongData from holder or SongButton; ensure selection exists
@@ -392,7 +512,7 @@ public class selected_songInfo : MonoBehaviour
if (sd == null) sd = SongDataHolder.SelectedSongData;
if (sd == null)
{
Debug.LogWarning("No song selected - cannot quick enter gameplay.");
LogVerbose("No song selected - cannot quick enter gameplay.");
return;
}
@@ -404,7 +524,7 @@ public class selected_songInfo : MonoBehaviour
return;
}
Debug.LogWarning($"QuickEnter clicked, selected song: {sd.songName} id={sd.songID} difficulty={sd.thisLevel_selectedDifficultyID}");
LogVerbose($"QuickEnter clicked, selected song: {sd.songName} id={sd.songID} difficulty={sd.thisLevel_selectedDifficultyID}");
// pass selection to BeatmapManager pending fields so newly loaded scene picks it up
BeatmapManager.SetPendingSong(sd, sd.thisLevel_selectedDifficultyID);
@@ -420,7 +540,7 @@ public class selected_songInfo : MonoBehaviour
private IEnumerator QuickEnterSequence()
{
Debug.LogWarning("QuickEnterSequence started: beginning fade");
LogVerbose("QuickEnterSequence started: beginning fade");
// Fade black mask in over 0.25 seconds
float duration = 0.25f;
if (blackMaskImage != null)
@@ -455,7 +575,7 @@ public class selected_songInfo : MonoBehaviour
blackMaskImage.color = c;
}
Debug.LogWarning("Fade complete, loading gameplay scene...");
LogVerbose("Fade complete, loading gameplay scene...");
// after black screen, load gameplay scene asynchronously and wait for completion
SceneManager.sceneLoaded += OnSceneLoadedAfterQuickEnter;
var asyncOp = SceneManager.LoadSceneAsync("gamePlay_gamePlay");
@@ -478,8 +598,8 @@ public class selected_songInfo : MonoBehaviour
private SongData FindSongDataFromSelectedButton()
{
var allButtons = FindObjectsOfType<SongButton>();
Debug.LogWarning($"FindSongDataFromSelectedButton: found {allButtons.Length} SongButton instances");
var allButtons = Object.FindObjectsByType<SongButton>(FindObjectsInactive.Exclude, FindObjectsSortMode.InstanceID);
LogVerbose($"FindSongDataFromSelectedButton: found {allButtons.Length} SongButton instances");
foreach (var sb in allButtons)
{
if (sb == null) continue;
@@ -490,7 +610,7 @@ public class selected_songInfo : MonoBehaviour
Image img = null;
if (field != null) img = field.GetValue(sb) as Image;
float alpha = img != null ? img.color.a : -1f;
Debug.LogWarning($"SongButton id field value for '{sb.name}': selected_boarder alpha={alpha}");
LogVerbose($"SongButton id field value for '{sb.name}': selected_boarder alpha={alpha}");
if (img != null && img.color.a > 0.5f)
{
@@ -501,7 +621,7 @@ public class selected_songInfo : MonoBehaviour
var soObj = soField.GetValue(sb);
if (soObj != null && soObj is SongData)
{
Debug.LogWarning($"Selected SongButton has thisSong_so assigned: {((SongData)soObj).songName}");
LogVerbose($"Selected SongButton has thisSong_so assigned: {((SongData)soObj).songName}");
return soObj as SongData;
}
}
@@ -511,11 +631,11 @@ public class selected_songInfo : MonoBehaviour
if (idField != null)
{
int id = (int)idField.GetValue(sb);
Debug.LogWarning($"Selected SongButton id = {id}");
LogVerbose($"Selected SongButton id = {id}");
var sd = SongDataLibrary.Instance != null ? SongDataLibrary.Instance.GetSongDataByID(id) : null;
if (sd != null)
{
Debug.LogWarning($"Found SongData by id: {sd.songName}");
LogVerbose($"Found SongData by id: {sd.songName}");
return sd;
}
}
@@ -523,10 +643,10 @@ public class selected_songInfo : MonoBehaviour
}
catch (System.Exception ex)
{
Debug.LogWarning("Exception while inspecting SongButton: " + ex.Message);
LogVerbose("Exception while inspecting SongButton: " + ex.Message);
}
}
Debug.LogWarning("FindSongDataFromSelectedButton: no selected SongButton found");
LogVerbose("FindSongDataFromSelectedButton: no selected SongButton found");
return null;
}
@@ -566,7 +686,7 @@ public class selected_songInfo : MonoBehaviour
if (selected == null)
{
Debug.LogWarning("OnSceneLoadedAfterQuickEnter: SelectedSongData is null");
LogVerbose("OnSceneLoadedAfterQuickEnter: SelectedSongData is null");
SceneManager.sceneLoaded -= OnSceneLoadedAfterQuickEnter;
// allow this object to be destroyed now
Destroy(this.gameObject);
@@ -574,26 +694,26 @@ public class selected_songInfo : MonoBehaviour
}
// find managers in the new scene
var beatmapManager = FindObjectOfType<BeatmapManager>();
var gameManager = FindObjectOfType<GameManager>();
var beatmapManager = Object.FindAnyObjectByType<BeatmapManager>();
var gameManager = Object.FindAnyObjectByType<GameManager>();
Debug.LogWarning($"selected song: {selected.songName} (id {selected.songID}), difficulty {selected.thisLevel_selectedDifficultyID}");
LogVerbose($"selected song: {selected.songName} (id {selected.songID}), difficulty {selected.thisLevel_selectedDifficultyID}");
// get chart TextAsset from SongData for current selected difficulty
TextAsset chartAsset = selected.GetChartFile(selected.thisLevel_selectedDifficultyID);
if (chartAsset == null)
{
Debug.LogWarning($"Chart file for difficulty {selected.thisLevel_selectedDifficultyID} not found on SongData {selected.songName}");
LogVerbose($"Chart file for difficulty {selected.thisLevel_selectedDifficultyID} not found on SongData {selected.songName}");
}
else
{
Debug.LogWarning($"Chart asset found, size={chartAsset.text?.Length ?? 0} chars");
LogVerbose($"Chart asset found, size={chartAsset.text?.Length ?? 0} chars");
}
// parse beatmap only and assign music, but DO NOT start spawning until player starts
if (beatmapManager != null && chartAsset != null)
{
Debug.LogWarning("Parsing chart JSON via BeatmapManager.ParseJsonOnly");
LogVerbose("Parsing chart JSON via BeatmapManager.ParseJsonOnly");
bool parsed = false;
try
{
@@ -601,21 +721,21 @@ public class selected_songInfo : MonoBehaviour
}
catch (System.Exception ex)
{
Debug.LogWarning("Exception during ParseJsonOnly: " + ex.Message + "\n" + ex.StackTrace);
LogVerbose("Exception during ParseJsonOnly: " + ex.Message + "\n" + ex.StackTrace);
}
Debug.LogWarning($"ParseJsonOnly returned {parsed}");
LogVerbose($"ParseJsonOnly returned {parsed}");
if (!parsed)
{
Debug.LogWarning("Failed to parse chart JSON from SongData chart file.");
LogVerbose("Failed to parse chart JSON from SongData chart file.");
}
else
{
Debug.LogWarning($"Beatmap parsed: beatmap is {(beatmapManager.beatmap != null ? "NOT null" : "null")}, parsedMusicFile={beatmapManager.parsedMusicFile}, globalDelaySeconds={beatmapManager.globalDelaySeconds}");
LogVerbose($"Beatmap parsed: beatmap is {(beatmapManager.beatmap != null ? "NOT null" : "null")}, parsedMusicFile={beatmapManager.parsedMusicFile}, globalDelaySeconds={beatmapManager.globalDelaySeconds}");
}
}
else
{
if (beatmapManager == null) Debug.LogWarning("BeatmapManager not found in gameplay scene");
if (beatmapManager == null) LogVerbose("BeatmapManager not found in gameplay scene");
}
// assign audio clip to GameManager.musicSource if available
@@ -639,7 +759,7 @@ public class selected_songInfo : MonoBehaviour
Debug.LogWarning("Failed to Play() for warmup: " + ex.Message);
}
Debug.LogWarning("Assigned SongData.audioFile to GameManager.musicSource.clip (playOnAwake disabled)");
LogVerbose("Assigned SongData.audioFile to GameManager.musicSource.clip (playOnAwake disabled)");
// Request PauseManager-driven pause (centralized)
RequestPauseManagerPause();
@@ -649,7 +769,7 @@ public class selected_songInfo : MonoBehaviour
// try to load by parsedMusicFile similar to pressStart normal mode
if (gameManager.musicSource != null && beatmapManager != null && !string.IsNullOrEmpty(beatmapManager.parsedMusicFile))
{
Debug.LogWarning($"Attempting Resources.Load for audio: {beatmapManager.parsedMusicFile}");
LogVerbose($"Attempting Resources.Load for audio: {beatmapManager.parsedMusicFile}");
var ac = Resources.Load<AudioClip>(beatmapManager.parsedMusicFile);
if (ac != null)
{
@@ -660,25 +780,25 @@ public class selected_songInfo : MonoBehaviour
{
gameManager.musicSource.mute = true;
gameManager.musicSource.Play();
Debug.LogWarning("Warmed audio playback (muted) after Resources.Load");
LogVerbose("Warmed audio playback (muted) after Resources.Load");
}
catch (System.Exception ex)
{
Debug.LogWarning("Failed to Play() for warmup after Resources.Load: " + ex.Message);
LogVerbose("Failed to Play() for warmup after Resources.Load: " + ex.Message);
}
Debug.LogWarning("Loaded audio via Resources.Load(parsedMusicFile) and disabled playOnAwake");
LogVerbose("Loaded audio via Resources.Load(parsedMusicFile) and disabled playOnAwake");
RequestPauseManagerPause();
}
else
{
Debug.LogWarning($"Resources.Load failed for '{beatmapManager.parsedMusicFile}'");
LogVerbose($"Resources.Load failed for '{beatmapManager.parsedMusicFile}'");
}
}
else
{
Debug.LogWarning("No audio assigned: selected.audioFile null and parsedMusicFile empty or musicSource missing");
LogVerbose("No audio assigned: selected.audioFile null and parsedMusicFile empty or musicSource missing");
}
}
}
@@ -689,16 +809,16 @@ public class selected_songInfo : MonoBehaviour
// Start coroutine to wait for player input (Space) to begin playback and spawning
// Use a safe host for coroutine in case this MonoBehaviour is destroyed unexpectedly
var pauseMgr = PauseManager.Instance ?? FindObjectOfType<PauseManager>();
var pauseMgr = PauseManager.Instance != null ? PauseManager.Instance : Object.FindAnyObjectByType<PauseManager>();
MonoBehaviour coroutineHost = (pauseMgr as MonoBehaviour) ?? (gameManager as MonoBehaviour) ?? (beatmapManager as MonoBehaviour) ?? this;
if (coroutineHost != null)
{
Debug.LogWarning("Starting WaitForPlayerStartAndBegin coroutine on host: " + coroutineHost.name);
LogVerbose("Starting WaitForPlayerStartAndBegin coroutine on host: " + coroutineHost.name);
coroutineHost.StartCoroutine(WaitForPlayerStartAndBegin(beatmapManager, gameManager));
}
else
{
Debug.LogWarning("No valid coroutine host found to start WaitForPlayerStartAndBegin.");
LogVerbose("No valid coroutine host found to start WaitForPlayerStartAndBegin.");
}
// unsubscribe from sceneLoaded
@@ -707,24 +827,24 @@ public class selected_songInfo : MonoBehaviour
private IEnumerator WaitForPlayerStartAndBegin(BeatmapManager beatmapManager, GameManager gameManager)
{
Debug.LogWarning("Waiting for player to press Space to start playback...");
LogVerbose("Waiting for player to press Space to start playback...");
// Wait until player presses Space
while (!Input.GetKeyDown(KeyCode.Space))
{
yield return null;
}
Debug.LogWarning("Player pressed Space. Preparing to start playback.");
LogVerbose("Player pressed Space. Preparing to start playback.");
// wait for NotePool prewarm to complete (block until finished to avoid hitch)
if (NotePool.Instance != null)
{
Debug.LogWarning("Waiting for NotePool prewarm to finish (blocking)...");
LogVerbose("Waiting for NotePool prewarm to finish (blocking)...");
while (!NotePool.Instance.IsPrewarmed)
{
yield return null;
}
Debug.LogWarning("NotePool prewarm completed.");
LogVerbose("NotePool prewarm completed.");
}
// ensure audio has been warmed (attempt play muted if not already playing)
@@ -739,18 +859,18 @@ public class selected_songInfo : MonoBehaviour
}
// Prewarm particle systems via AnimationController to avoid first-play hitch
var anim = AnimationController.Global ?? FindObjectOfType<AnimationController>();
var anim = AnimationController.Global != null ? AnimationController.Global : Object.FindAnyObjectByType<AnimationController>();
if (anim != null)
{
Debug.LogWarning("Starting AnimationController particle prewarm (will wait until complete)...");
LogVerbose("Starting AnimationController particle prewarm (will wait until complete)...");
// yield until the prewarm completes
yield return StartCoroutine(anim.PrewarmParticlesRoutine(2));
Debug.LogWarning("AnimationController particle prewarm complete.");
LogVerbose("AnimationController particle prewarm complete.");
}
// Unpause via PauseManager
var pauseMgr = PauseManager.Instance ?? FindObjectOfType<PauseManager>();
pauseMgr?.Pause(false);
var pauseMgr = PauseManager.Instance != null ? PauseManager.Instance : Object.FindAnyObjectByType<PauseManager>();
if (pauseMgr != null) pauseMgr.Pause(false);
// small buffer to avoid hitching immediately after unpause: wait configured delay from GameManager
// Use scaled WaitForSeconds so PauseManager (Escape) will pause the countdown
@@ -761,12 +881,12 @@ public class selected_songInfo : MonoBehaviour
// Start spawning notes
if (beatmapManager != null && beatmapManager.beatmap != null)
{
Debug.LogWarning("Calling beatmapManager.LoadBeatmap");
LogVerbose("Calling beatmapManager.LoadBeatmap");
beatmapManager.LoadBeatmap(beatmapManager.beatmap);
}
else
{
Debug.LogWarning("Cannot start beatmap: beatmapManager or beatmap is null.");
LogVerbose("Cannot start beatmap: beatmapManager or beatmap is null.");
}
// fade out black mask in gameManager if available
@@ -781,14 +901,14 @@ public class selected_songInfo : MonoBehaviour
float delay = beatmapManager != null ? beatmapManager.globalDelaySeconds : 0f;
if (gameManager.musicSource.clip != null)
{
Debug.LogWarning($"Starting audio playback with delay {delay}");
LogVerbose($"Starting audio playback with delay {delay}");
// Use GameManager helper to ensure unmute and start playback reliably
try { gameManager.PlayMusicWithDelay(delay); }
catch (System.Exception ex) { Debug.LogWarning("Failed to start music via GameManager.PlayMusicWithDelay: " + ex); }
catch (System.Exception ex) { LogVerbose("Failed to start music via GameManager.PlayMusicWithDelay: " + ex); }
}
else
{
Debug.LogWarning("GameManager.musicSource.clip is null; skipping audio playback.");
LogVerbose("GameManager.musicSource.clip is null; skipping audio playback.");
}
}
@@ -809,7 +929,7 @@ public class selected_songInfo : MonoBehaviour
Debug.LogWarning($"enterDetailPageButton assigned={(enterDetailPageButton==null?"NULL":"ASSIGNED")}");
Debug.LogWarning($"blackMaskImage assigned={(blackMaskImage==null?"NULL":"ASSIGNED")}");
Debug.LogWarning($"SongDataHolder.SelectedSongData={(SongDataHolder.SelectedSongData==null?"NULL":SongDataHolder.SelectedSongData.songName)}");
var allButtons = FindObjectsOfType<SongButton>();
var allButtons = Object.FindObjectsByType<SongButton>(FindObjectsInactive.Exclude, FindObjectsSortMode.InstanceID);
Debug.LogWarning($"Found {allButtons.Length} SongButton instances in scene");
for (int i = 0; i < allButtons.Length; i++)
{
@@ -825,16 +945,16 @@ public class selected_songInfo : MonoBehaviour
private void RequestPauseManagerPause()
{
if (pauseRequested) return;
var pm = PauseManager.Instance ?? FindObjectOfType<PauseManager>();
var pm = PauseManager.Instance != null ? PauseManager.Instance : Object.FindAnyObjectByType<PauseManager>();
if (pm != null)
{
pm.Pause(true);
Debug.LogWarning("selected_songInfo: PauseManager.Pause(true) requested (centralized)");
LogVerbose("selected_songInfo: PauseManager.Pause(true) requested (centralized)");
pauseRequested = true;
}
else
{
Debug.LogWarning("selected_songInfo: PauseManager not found when requesting pause");
LogVerbose("selected_songInfo: PauseManager not found when requesting pause");
}
}