[ExecuteAlways]
public class ExecuteAlwaysTest : MonoBehaviour
{
// Start is called before the first frame updatevoid Start()
{
Debug.Log("Start");
}
}
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
{
var time = playable.GetTime();
var duration = playable.GetDuration();
}
public class CustomTimelineClipPlayable : PlayableBehaviour
{
public Color StartColor = Color.white;
public Color EndColor = Color.white;
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
{
var image = playerData as Image;
if (image != null)
{
var duration = playable.GetDuration();
var time = playable.GetTime();
image.color = Color.Lerp(StartColor, EndColor, (float) (time / duration));
}
}
}
[System.Serializable]
public class CustomTimeLinePlayableAsset : PlayableAsset
{
public Color startColor = Color.white;
public Color endColor = Color.white;
// Factory method that generates a playable based on this asset
public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
{
var playable = ScriptPlayable<CustomTimelineClipPlayable>.Create(graph);
var behaviour = playable.GetBehaviour();
// PlayableへInspectorでの設定値を渡しています。
behaviour.StartColor = startColor;
behaviour.EndColor = endColor;
return playable;
}
}
Trackを自作する
Timelineで使うTrackを作成します。
[TrackClipType(typeof(CustomTimeLinePlayableAsset))]
[TrackBindingType(typeof(Image))]
public class CustomTimelineTrack : TrackAsset
{
}