48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.Playables;
|
|||
|
using UnityEngine.Timeline;
|
|||
|
|
|||
|
namespace Thousandto.Launcher.ExternalLibs
|
|||
|
{
|
|||
|
//脚本激活的混合处理逻辑
|
|||
|
public class ScriptActivationMixBehaviour : PlayableBehaviour
|
|||
|
{
|
|||
|
//当前混合的TimelineClip
|
|||
|
private TimelineClip[] _clips;
|
|||
|
public TimelineClip[] Clips {
|
|||
|
get { return _clips; }
|
|||
|
set { _clips = value; }
|
|||
|
}
|
|||
|
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
|
|||
|
{
|
|||
|
var go = playerData as GameObject;
|
|||
|
if (go == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < playable.GetInputCount(); i++)
|
|||
|
{
|
|||
|
var inputPlayable = (ScriptPlayable<ScriptActivationBehaviour>)playable.GetInput(i);
|
|||
|
var inputBehaviour = inputPlayable.GetBehaviour();
|
|||
|
if (inputBehaviour != null)
|
|||
|
{
|
|||
|
if (playable.GetInputWeight(i) > 0)
|
|||
|
{
|
|||
|
inputBehaviour.SetActive(go, true);
|
|||
|
inputBehaviour.SendMessage(_clips[i].duration, inputPlayable.GetTime());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
inputBehaviour.SetActive(go, false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|