53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using UnityEngine;
|
||
using UnityEngine.Playables;
|
||
using UnityEngine.Timeline;
|
||
|
||
namespace GameWrapper.Timeline.CommonAction
|
||
{
|
||
/// <summary>
|
||
/// 通用动作Clip(独立版本)
|
||
/// </summary>
|
||
public class CommonActionClip : PlayableAsset, ITimelineClipAsset
|
||
{
|
||
[Tooltip("动作类型")]
|
||
public ECommonActionType actionType = ECommonActionType.ActiveSet;
|
||
|
||
[Tooltip("参数1 - 不同动作类型含义不同,详见枚举注释")]
|
||
public int actionParam1 = 1;
|
||
|
||
[Tooltip("参数2 - 用于某些需要额外参数的动作类型")]
|
||
public int actionParam2 = 0;
|
||
|
||
[Tooltip("字符串参数 - 用于需要名称的动作类型(如动画名称)")]
|
||
public string stringParam = "";
|
||
|
||
[Tooltip("颜色参数 - 用于MaterialChange等需要颜色的动作")]
|
||
public Color colorParam = Color.white;
|
||
|
||
[Tooltip("浮点参数 - 用于需要精确数值的动作(如透明度、强度等)")]
|
||
[Range(0f, 1f)]
|
||
public float floatParam = 1f;
|
||
|
||
public ClipCaps clipCaps
|
||
{
|
||
get { return ClipCaps.None; }
|
||
}
|
||
|
||
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
|
||
{
|
||
var playable = ScriptPlayable<CommonActionBehaviour>.Create(graph);
|
||
var behaviour = playable.GetBehaviour();
|
||
|
||
// 传递Clip数据给Behaviour
|
||
behaviour.actionType = actionType;
|
||
behaviour.actionParam1 = actionParam1;
|
||
behaviour.actionParam2 = actionParam2;
|
||
behaviour.stringParam = stringParam;
|
||
behaviour.colorParam = colorParam;
|
||
behaviour.floatParam = floatParam;
|
||
|
||
return playable;
|
||
}
|
||
}
|
||
}
|