Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CreatePlayable isn't called

Discussion in 'Timeline' started by luffyklose0822, Jul 29, 2022.

  1. luffyklose0822

    luffyklose0822

    Joined:
    Aug 3, 2018
    Posts:
    5
    Hello guys, I'm making a custom timeline clip but I got a strange bug.

    I have created a track:
    Code (CSharp):
    1. [TrackColor(0.8f, 0.2f, 1f)]
    2. [TrackClipType(typeof(PlayerMoveClip))]
    3. [TrackBindingType(typeof(PlayerController))]
    4. public class PlayerMoveTrack : TrackAsset
    5. {
    6.     protected override Playable CreatePlayable(PlayableGraph graph, GameObject gameObject, TimelineClip clip)
    7.     {
    8.         PlayerMoveClip c = (PlayerMoveClip)clip.asset;
    9.         c.clipStart = clip.start;
    10.         c.clipEnd = clip. End;
    11.  
    12.         return ScriptPlayable<PlayerMoveBehavior>.Create(graph);
    13.     }
    14. }
    And here's my clip:
    Code (CSharp):
    1. [Serializable]
    2. public class PlayerMoveClip : PlayableAsset, ITimelineClipAsset
    3. {
    4.     public double ClipStart => clipStart;
    5.     public double ClipEnd => clipEnd;
    6.  
    7.     [HideInInspector] public PlayerMoveBehavior template = new PlayerMoveBehavior();
    8.    
    9.     public Vector3 targetPosition; //for movement
    10.     public double clipStart;
    11.     public double clipEnd;
    12.    
    13.     public ClipCaps clipCaps
    14.     {
    15.         get { return ClipCaps.None; }
    16.     }
    17.  
    18.     public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)
    19.     {
    20.         Debug.Log("Create playable");
    21.         var playable = ScriptPlayable<PlayerMoveBehavior>.Create(graph, template);
    22.         PlayerMoveBehavior clone = playable.GetBehaviour();
    23.         clone.targetPosition = targetPosition;
    24.         clone.ClipStart = clipStart;
    25.         clone.ClipEnd = clipEnd;
    26.         return playable;
    27.     }
    28. }
    But I never got the "Create playable" message, I think I have made the correct settings just as what I did before, but the CreatePlayable method is just not called when the game runs.