Search Unity

Change clip name with custom playable

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

  1. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    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 clip.name parameter but haven't been able to figure out where it is or how to reference it
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    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

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    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):
    1.    
    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.             }
    14.  
    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.     }