Search Unity

Icon of Custom Timeline Track

Discussion in 'Timeline' started by atomlovelace, Dec 20, 2017.

  1. atomlovelace

    atomlovelace

    Joined:
    Mar 12, 2015
    Posts:
    5
    Is there a way to change the icon of a custom Timeline track?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It's undocumented, and may change in the future, but you can put a .png where the filename has the same name as your track (e.g. MyCustomTrack.png) in Assets/Gizmos/.
     
  3. atomlovelace

    atomlovelace

    Joined:
    Mar 12, 2015
    Posts:
    5
    This worked! Thanks.
     
  4. bfe_gio

    bfe_gio

    Joined:
    Apr 7, 2016
    Posts:
    9
    I'm on 2018.1 and this doesn't seem to work. Tracks appear to always use the icon of whatever their binding object type is - so if I have a track with a binding type of Animator, the track shows the Animator icon. Tracks that don't have a binding type always use the "Scriptable Object" icon - this one:

    My custom icon does get recognized by Unity, as it shows up when selecting the track asset type itself in the project view. It's a type that's defined in a DLL, and within a namespace, but putting the icon file into folders that match the namespace definition does get that showing when the type is shown in the inspector.

    Is the procedure for this different now, or is there no longer a way to override the icon on the Timeline track?

    (also when will we be able to customize how tracks/clips are drawn? That would be fantastic for things like tracks that use a curve along their duration)
     

    Attached Files:

  5. tree_fiddler_2000

    tree_fiddler_2000

    Joined:
    Dec 5, 2018
    Posts:
    15
    Hi, I just tried this too, no luck. Is there a new that this is supported?

    Cheers
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    This still works for me. But it must be in the Assets/Gizmos folder (not any other gizmos folder, just that one).
     
  7. Romano

    Romano

    Joined:
    Nov 27, 2013
    Posts:
    76
    Working in 2019.3, but had to restart Unity to get it to show up.
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can now also use a TrackEditor to supply the icon (icon field inside TrackDrawOptions), which is more useful if you want to change the icon based on the state of the track.

    Code (CSharp):
    1. [CustomTimelineEditor(typeof(ShotTrack))]
    2. public class ShotTrackEditor : TrackEditor
    3. {
    4.     public override TrackDrawOptions GetTrackOptions(TrackAsset track, Object binding)
    5.     {
    6.         var options = base.GetTrackOptions(track, binding);
    7.         if (track.hasClips)
    8.             options.minimumHeight = ((ShotTrack) track).previewSize;
    9.         return options;
    10.     }
    11. }
     
  9. sbsmith

    sbsmith

    Joined:
    Feb 7, 2013
    Posts:
    126
    Hello, I've been reading the docs and it isn't clear how to get the state of the track from the TrackEditor. I'd like to copy the functionality of Animator Tracks where the icon changes when a clip is active or not.
     
  10. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    Here's how I was able to apply a built-in icon to my custom timeline track:

    Code (CSharp):
    1.  
    2. using UnityEditor;
    3. using UnityEditor.Timeline;
    4. using UnityEngine;
    5. using UnityEngine.Timeline;
    6.  
    7. [CustomTimelineEditor(typeof(AnimatorTriggerTrack))]
    8. public class AnimatorTriggerTrackEditor : TrackEditor
    9. {
    10.     override public TrackDrawOptions GetTrackOptions(TrackAsset track, Object binding)
    11.     {
    12.         var options = base.GetTrackOptions(track, binding);
    13.         // See:  https://github.com/halak/unity-editor-icons
    14.         options.icon = (Texture2D)EditorGUIUtility.IconContent("d_PlayButton").image;
    15.         return options;
    16.     }
    17. }
     
    sabojako likes this.