hold音符补丁 备份

This commit is contained in:
FloatGaming
2026-03-03 14:07:39 +08:00
parent b8704629a3
commit 9011fa022e
36 changed files with 2721 additions and 256 deletions
@@ -55,6 +55,7 @@ public class delayTapperPrefab : MonoBehaviour
private bool isPaused = false;
private bool isRunning = false;
private float currentElapsed = 0f;
private Dictionary<AudioSource, bool> originalMuteStates = new Dictionary<AudioSource, bool>();
private const string DELAY_PREFS_KEY = "UserGlobalDelaySeconds";
@@ -147,6 +148,55 @@ public class delayTapperPrefab : MonoBehaviour
// 开始加载音频
StartCoroutine(PrepareAudioAndEnableButton());
// 查找场景中所有的 AudioSource 并将非指定的 AudioSource 静音
MuteOtherAudioSources();
}
private void OnDestroy()
{
// 销毁时恢复音频源状态
RestoreAudioSources();
}
private void MuteOtherAudioSources()
{
originalMuteStates.Clear();
// 查找场景中所有的 AudioSource (包括非激活的)
AudioSource[] allAudioSources = FindObjectsOfType<AudioSource>(true);
foreach (var asrc in allAudioSources)
{
// 如果是指定的两个音频源之一,不静音
if (asrc == audioSource || asrc == hit_sfx_as)
{
// 确保它们是取消静音的,以便能听到声音
asrc.mute = false;
continue;
}
// 记录原始静音状态
if (!originalMuteStates.ContainsKey(asrc))
{
originalMuteStates[asrc] = asrc.mute;
asrc.mute = true; // 静音
}
}
Debug.Log($"[delayTapperPrefab] 已静音 {originalMuteStates.Count} 个音频源");
}
private void RestoreAudioSources()
{
int restoredCount = 0;
foreach (var kvp in originalMuteStates)
{
if (kvp.Key != null)
{
kvp.Key.mute = kvp.Value;
restoredCount++;
}
}
originalMuteStates.Clear();
Debug.Log($"[delayTapperPrefab] 已恢复 {restoredCount} 个音频源的静音状态");
}
public void OnResetButtonClicked()