Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Change clip name with custom playable

Discussion in 'Timeline' started by edwon, Oct 9, 2017.

  1. edwon


    Apr 24, 2011
    I want to change the name of individual clips from within my custom playable (which I originally made using the custom playable wizard)

    Is this possible? I've being trying to find a parameter but haven't been able to figure out where it is or how to reference it
  2. seant_unity


    Unity Technologies

    Aug 25, 2015
    It's possible, but far from ideal. You need to do it from your custom track, which has access to the TimelineClips. TimelineClip has a displayName property you can change.

    CreateTrackMixer() is the easiest place to put it, but it's very much out of place to do renaming there. OnValidate() might work better.
  3. edwon


    Apr 24, 2011
    ok, got it working, yeah it's clunky, but it works!

    would be alot better if there was a reference to the clip inside the behaviour itself and I could set the name from there, but oh well

    here's an example of how I did it

    Code (CSharp):
    2. public class TLBodyTargetAnimTrack : TrackAsset
    3.     {
    4.         public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    5.         {
    6.             foreach (TimelineClip clip in m_Clips)
    7.             {
    8.                 TLBodyTargetAnimClip mouthClip = clip.asset as TLBodyTargetAnimClip;
    9.                  // the template variable comes from classes made with the playable wizard
    10.                 TLBodyTargetAnimBehaviour behaviour = mouthClip.template;
    11.                 // name the track with my variables value
    12.                 clip.displayName = "myVariable = " + behaviour.myVariable;
    13.             }
    15.             ScriptPlayable<TLBodyTargetAnimMixerBehaviour> playable = ScriptPlayable<TLBodyTargetAnimMixerBehaviour>.Create( graph, inputCount );
    16.             playable.GetBehaviour().bodyTarget = go.GetComponent<PlayableDirector>().GetGenericBinding( this ) as PetTimelineBodyTarget;
    17.             return playable;
    18.         }
    19.     }
    arvzg and AA-Matt like this.