Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active May 12, 2021 10:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/96821e6b61adf5c733914b069b624203 to your computer and use it in GitHub Desktop.
Save tsubaki/96821e6b61adf5c733914b069b624203 to your computer and use it in GitHub Desktop.
UnityのTimel inで、クリックしたらクリップの末まで移動する
using UnityEngine;
using UnityEngine.Playables;
public class ClickToEndBehaviour : PlayableBehaviour
{
private PlayableDirector director { get; set; }
public override void OnPlayableCreate(Playable playable)
{
director = (playable.GetGraph().GetResolver() as PlayableDirector);
}
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
{
if (Input.GetMouseButtonDown(0))
{
var diff = playable.GetDuration() - playable.GetTime();
director.time += diff;
}
}
}
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class ClickToEndClip : PlayableAsset, ITimelineClipAsset
{
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
return ScriptPlayable<ClickToEndBehaviour>.Create (graph);
}
public ClipCaps clipCaps { get; }
}
using UnityEngine.Timeline;
[TrackColor (1f, 0.2794118f, 0.7117646f)]
[TrackClipType (typeof(ClickToEndClip))]
public class ClicktoEndTrack : TrackAsset{}
@tsubaki
Copy link
Author

tsubaki commented Nov 13, 2019

タイムマシーン

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment