添加场景、对应场景代码
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace GameFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// UI 事件音效触发器。
|
||||
/// 挂到按钮上,鼠标悬停/选中时播放 selectSFX,点击/提交时播放 submitSFX。
|
||||
/// </summary>
|
||||
public class UIEventTrigger : MonoBehaviour,
|
||||
IPointerEnterHandler,
|
||||
IPointerDownHandler,
|
||||
ISelectHandler,
|
||||
ISubmitHandler
|
||||
{
|
||||
[SerializeField] AudioData selectSFX;
|
||||
[SerializeField] AudioData submitSFX;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
PlaySFX(selectSFX);
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
PlaySFX(submitSFX);
|
||||
}
|
||||
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
PlaySFX(selectSFX);
|
||||
}
|
||||
|
||||
public void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
PlaySFX(submitSFX);
|
||||
}
|
||||
|
||||
void PlaySFX(AudioData data)
|
||||
{
|
||||
if (AudioManager.Instance != null && data != null)
|
||||
AudioManager.Instance.PlaySFX(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user