Files
zeling_v2/Assets/_Game/Scripts/Feedback/SceneFeedback.cs
2026-05-19 16:04:40 +08:00

42 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using UnityEngine;
using MoreMountains.Feedbacks;
namespace BaseGames.Feedback
{
/// <summary>
/// 场景物件反馈适配器(防腐层)。
/// 将世界/关卡对象(机关、平台、谜题等)与 FeelMMF_Player完全解耦
/// - 世界对象只引用 SceneFeedback不知道 Feel 的存在
/// - 若将来替换 Feel只修改此文件即可所有世界对象无需变动
///
/// 用法:
/// 1. 在需要反馈的 GameObject 上添加 SceneFeedback 组件
/// 2. 在 Inspector 中将 MMF_Player 拖入 _player 槽位
/// 3. 调用者持有 [SerializeField] SceneFeedback 引用,调用 .Play() 或 yield return .PlayAndWait()
/// </summary>
[AddComponentMenu("BaseGames/Feedback/Scene Feedback")]
public class SceneFeedback : MonoBehaviour
{
[SerializeField] private MMF_Player _player;
/// <summary>播放此反馈。若 _player 未配置则静默跳过。</summary>
public void Play() => _player?.PlayFeedbacks();
/// <summary>立即停止正在播放的反馈。</summary>
public void Stop() => _player?.StopFeedbacks();
/// <summary>
/// 播放反馈并等待其完成后继续。若 _player 未配置则立即返回。
/// 用于需要等待淡出/淡入完成后再执行下一步的场景(如传送、开门等)。
/// </summary>
public IEnumerator PlayAndWait()
{
if (_player == null) yield break;
_player.PlayFeedbacks();
while (_player.IsPlaying)
yield return null;
}
}
}