Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Custom track asset get trackbinding

Discussion in 'Timeline' started by Censureret, Oct 10, 2020.

  1. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    361
    So i have the following track:

    Code (CSharp):
    1.     [TrackBindingType(typeof(Transform))]
    2.     [TrackClipType(typeof(AddBloodClip))]
    3.     public class AddBloodTrack : TrackAsset
    4.     {
    5.     }
    How can i get the TrackBinding in my clip?

    i have tried the following:

    Code (CSharp):
    1.   public HumanBodyBones bone;
    2.         public ExposedReference<Transform> target;
    3.  
    4.        
    5.         public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    6.         {
    7.             var playable = ScriptPlayable<AddBloodBehaviour>.Create(graph);
    8.  
    9.             AddBloodBehaviour epb = playable.GetBehaviour();
    10.             epb.target = target.Resolve(graph.GetResolver());
    11.             epb.bone = bone;
    12.            
    13.             return playable;
    14.         }
    but without luck?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    In PlayableBehaviour.ProcessFrame, the track binding is passed as the last parameter - however you will need to cast it to a transform (or whatever the binding type for the track is).

    The code above lets you assign a binding to a clip instead of a track (similar to ControlTracks).
     
  3. dawsone

    dawsone

    Joined:
    Oct 8, 2020
    Posts:
    1
    • The Track class represents a custom track.
    • The Clip class represents a clip on this track. Note that it defines the clip caps, and contains a 'Template' of the Behaviour type. This template is used when creating the corresponding playable in the underlying playable graph.
    • This Behaviour then contains the data representing the contents of the clip, exposed in the 'Template' part of the inspector when selecting a clip.
    • The track creates one instance of the Mixer Behaviour playable when the playable graph is build. And this mixer is responsible for producing the final outcome.