How to change TimelineClip's color?

As mention on title, I want to change every Clip’s color base on it’s state, is there a way to do this?6319716--700488--upload_2020-9-17_10-56-55.png

By the way, Unity has provide a way to chang the whole track’s color:

[TrackColor(0f, 1f, 0f)]

Here’s what I’ve been doing.

An actor clip contains an actor profile, that has a colour as one of the fields. I use THAT as the clip colour so we can see straight away what character drives the clip.

    [CustomTimelineEditor ( typeof ( ActorClip ) )]
    public class ActorClipEditor : ClipEditor
    {
        public override ClipDrawOptions GetClipOptions ( TimelineClip clip )
        {
            var clipOptions = base.GetClipOptions ( clip );
            var characterProfile = ( ( ActorClip ) clip.asset ).behaviour.characterProfile;
            clipOptions.highlightColor = characterProfile?.ConversationColor ?? Color.grey;
            return clipOptions;
        }
    }
3 Likes

Thanks for your help, but I can’t found any info about ‘ClipEditor’ or ‘ClipDrawOptions’, can you tell me which version of Unity you are using?

I’m using 2020, but … I’m pretty sure it’s been available since UnityEngine.Timeline.

I took a look at ClipEditor, and it returned this (ILspy would be even better):

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
namespace UnityEditor.Timeline
{
public class ClipEditor
{
public ClipEditor ( );
public virtual void DrawBackground ( TimelineClip clip, ClipBackgroundRegion region );
public virtual ClipDrawOptions GetClipOptions ( TimelineClip clip );
public Color GetDefaultHighlightColor ( TimelineClip clip );
public string GetErrorText ( TimelineClip clip );
public virtual void GetSubTimelines ( TimelineClip clip, PlayableDirector director, List subTimelines );
public virtual void OnClipChanged ( TimelineClip clip );
public virtual void OnCreate ( TimelineClip clip, TrackAsset track, TimelineClip clonedFrom );
}
}

1 Like

The solution posted by @VOTRUBEC is spot on. ClipEditors were introduced in 2019.2, IIRC.

1 Like