yyl
6 天以前 7789222416b7f43b1b425e8048bb49b4b8b0685c
125 战斗 切换到后台的战斗不播放任何声音
3个文件已修改
50 ■■■■■ 已修改文件
Main/Component/UI/Effect/BattleEffectPlayer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BaseBattleWin.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/Sound/BattleSoundManager.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Component/UI/Effect/BattleEffectPlayer.cs
@@ -411,7 +411,7 @@
        Spine.Animation animation = spineAnimationState.Data.SkeletonData.Animations.First();
        spineAnimationState.SetAnimation(0, animation, effectConfig.isLoop != 0);
        SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
        // SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
    }
@@ -467,7 +467,7 @@
        blocker.onSortingChanged = OnSortingChanged;
        SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
        // SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
    }
Main/System/Battle/BaseBattleWin.cs
@@ -65,6 +65,8 @@
        if (BattleManager.Instance.storyBattleField != null)
            BattleManager.Instance.storyBattleField.IsPause = false;
        battleField?.SetFocus(false);
        if (battleField != null)
        {
            battleField.OnRoundChange -= OnRoundChange;
Main/System/Battle/Sound/BattleSoundManager.cs
@@ -46,7 +46,46 @@
            currentSpeedRatio = battleField.speedRatio;
            hasFocus = battleField.IsFocus();
        }
#if UNITY_EDITOR
        // 监听编辑器暂停事件
        UnityEditor.EditorApplication.pauseStateChanged -= OnEditorPauseStateChanged;
        UnityEditor.EditorApplication.pauseStateChanged += OnEditorPauseStateChanged;
#endif
    }
#if UNITY_EDITOR
    /// <summary>
    /// 编辑器暂停状态变化回调
    /// </summary>
    private void OnEditorPauseStateChanged(UnityEditor.PauseState pauseState)
    {
        if (pauseState == UnityEditor.PauseState.Paused)
        {
            BattleDebug.LogError($"<color=yellow>BattleSoundManager [{battleField.guid}]: 编辑器暂停,停止所有音效</color>");
            for (int i = activeAudioSources.Count - 1; i >= 0; i--)
            {
                var source = activeAudioSources[i];
                if (source != null)
                {
                    source.Stop();
                }
            }
        }
        else if (pauseState == UnityEditor.PauseState.Unpaused)
        {
            BattleDebug.LogError($"<color=green>BattleSoundManager [{battleField.guid}]: 编辑器恢复</color>");
            for (int i = activeAudioSources.Count - 1; i >= 0; i--)
            {
                var source = activeAudioSources[i];
                if (source != null)
                {
                    source.Play();
                }
            }
        }
    }
#endif
    
    /// <summary>
    /// 初始化音频源池
@@ -409,6 +448,11 @@
            battleField.OnFocusChange -= OnFocusChanged;
        }
        
#if UNITY_EDITOR
        // 取消订阅编辑器暂停事件
        UnityEditor.EditorApplication.pauseStateChanged -= OnEditorPauseStateChanged;
#endif
        StopAllSounds();
        
        // 销毁所有 AudioSource 组件