71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using Sirenix.OdinInspector;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace SLSUtilities.Feedback
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 单个反馈序列的完整数据定义,是 Feedback 系统的核心 ScriptableObject。
|
|||
|
|
/// 包含多条轨道(Track),每条轨道包含按时间排列的片段(Clip)。
|
|||
|
|
/// </summary>
|
|||
|
|
[CreateAssetMenu(fileName = "NewFeedbackData", menuName = "SLS/Feedback/FeedbackData")]
|
|||
|
|
public class FeedbackData : SerializedScriptableObject
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 父级集合引用,由 FeedbackDataCollection 自动维护。
|
|||
|
|
/// </summary>
|
|||
|
|
[ReadOnly, ShowInInspector]
|
|||
|
|
public FeedbackDataCollection parentCollection;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 用于字典索引的名称,在 FeedbackDataCollection 中按此名称查找。
|
|||
|
|
/// </summary>
|
|||
|
|
[Title("Editor Settings")]
|
|||
|
|
public string feedbackName;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 全局默认的时间设置。Clip 可选择覆盖此设置。
|
|||
|
|
/// </summary>
|
|||
|
|
[Title("Time Settings (Default)")]
|
|||
|
|
public FeedbackTimeSettings defaultTimeSettings = new FeedbackTimeSettings();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 反馈轨道列表,多条轨道天然并行播放。
|
|||
|
|
/// </summary>
|
|||
|
|
[Title("Feedback Tracks")]
|
|||
|
|
[ListDrawerSettings(ShowFoldout = true, ListElementLabelName = "trackName")]
|
|||
|
|
public List<FeedbackTrack> tracks = new List<FeedbackTrack>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 所有轨道的最大时长。
|
|||
|
|
/// </summary>
|
|||
|
|
public float TotalDuration => tracks.Count > 0 ? tracks.Max(t => t.TotalDuration) : 0f;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 运行时预览:通过 FeedbackManager 播放此反馈。
|
|||
|
|
/// 仅在 Play 模式下可用。
|
|||
|
|
/// </summary>
|
|||
|
|
[Button("Preview", ButtonSizes.Medium)]
|
|||
|
|
[EnableIf("@UnityEngine.Application.isPlaying")]
|
|||
|
|
public void Preview()
|
|||
|
|
{
|
|||
|
|
if (!Application.isPlaying)
|
|||
|
|
{
|
|||
|
|
Debug.LogWarning("[FeedbackData] Preview is only available in Play mode.");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (FeedbackManager.Instance == null)
|
|||
|
|
{
|
|||
|
|
Debug.LogWarning("[FeedbackData] Preview failed: FeedbackManager not found in scene. " +
|
|||
|
|
"Add a GameObject with FeedbackManager component.");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
FeedbackPlayer player = FeedbackManager.Instance.Play(this);
|
|||
|
|
Debug.Log($"[FeedbackData] Previewing '{feedbackName}' (Duration: {TotalDuration:F2}s)");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|