- 新增 TerminalUIAudio 事件通知与 TerminalUIAudioBehaviour 组件 - TerminalButton/TerminalMenuItemView/SelectItem/SliderItem 接入悬停与点击音效 - AudioManager 监听 TerminalUIEvent 播放 menu_hover/menu_click - 新增 PauseMenu 环境音状态及恢复逻辑 - 新增 MainMenuStage FMOD 参数控制 - BaseButton 调用基类 DoStateTransition 保证状态事件正确触发 - 为 TerminalChapterPanel Prefab 添加 TerminalUIAudioBehaviour
58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using AibisDream;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.UI
|
|
{
|
|
[RequireComponent(typeof(BaseButton))]
|
|
[DisallowMultipleComponent]
|
|
public class TerminalUIAudioBehaviour : MonoBehaviour
|
|
{
|
|
private BaseButton _button;
|
|
private SelectionType _prevState = SelectionType.Normal;
|
|
|
|
private void Awake()
|
|
{
|
|
if (TryGetComponent<TerminalButton>(out _))
|
|
{
|
|
enabled = false;
|
|
return;
|
|
}
|
|
|
|
_button = GetComponent<BaseButton>();
|
|
_button.onStateTransition.AddListener(OnStateTransition);
|
|
_button.onClick.AddListener(OnClick);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (_button == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_button.onStateTransition.RemoveListener(OnStateTransition);
|
|
_button.onClick.RemoveListener(OnClick);
|
|
}
|
|
|
|
private void OnStateTransition(SelectionType state, bool instant)
|
|
{
|
|
if (_button.interactable
|
|
&& state == SelectionType.Highlighted
|
|
&& _prevState == SelectionType.Normal)
|
|
{
|
|
TerminalUIAudio.NotifyHover();
|
|
}
|
|
|
|
_prevState = state;
|
|
}
|
|
|
|
private void OnClick()
|
|
{
|
|
if (_button != null && _button.interactable)
|
|
{
|
|
TerminalUIAudio.NotifyClick();
|
|
}
|
|
}
|
|
}
|
|
}
|