Hi, I would like to customize the markers and clip styles in the timeline editor for an asset I am making.
For now I know that I can create new markers with custom styles using the Attribute:
[CustomStyle(“Mystyle”)]
And that allows me to set the Width, Height and background-color properties. Other properties like color, background-color or -unity-background-image-color-tint do not do anything.
I would like something more flexible where I could dynamically change the marker image/style depending on its state (which could be set in the inspector). For example, the Signal Emitter marker has a special icon when no signals are attached.
In my setup, I have to create a new Marker class for each state just so that I can have different icons for each. It would be a lot nicer If I could have a single custom marker that changes visual and functionality depending on its state.
You can draw an overlay on top of a marker by using a MarkerEditor:
public class MyMarker : Marker { }
//Make sure to put this class in its own file in an Editor directory, so that it is not included in a build
[CustomTimelineEditor(typeof(MyMarker))]
public class MyMarkerEditor : MarkerEditor
{
public override void DrawOverlay(IMarker marker, MarkerUIStates uiState, MarkerOverlayRegion region)
{
EditorGUI.DrawRect(region.markerRegion, Color.cyan);
}
}
So I made the change to have a single Marker type with different states.
But now I have a new problem. When I copy paste some markers they set to the default state instead of keeping the state of the copied marker. By state I mean I have a property field on my marker which I can change in the inspector.
In my workflow there is a ton of copy-pasting because I use a lot of markers, having to set each marker manually after they are copied would be a deal-breaker.
Any advice, maybe there’s an editor function that I can override for copy-pasting? … I’ll be very sad if I have to change everything back since it took me an entire day to make that change.
But in the end I won’t use the state stuff, I was overcomplicated things for nothing…
Thank you for the help though, I’ll still use the MarkerEditor code for better customization
When you have two or more markers in the same space, the default marker adds a little “+” icon on top of the marker.
My overlay hides that little “+” icon. The thing is that I do not know how to get the information that two markers are overlapping so that I can add my own little “+”.
Unfortunately, the overlay is drawn on top of the markers, which includes the little + icon. The best you can do is to check the other markers on the track, and display a + icon if two markers are ‘‘close’’ (their time is approximately equal). This is what we do internally.
For some reason the + icon just started appearing without me writing the code for it. I wonder if the script execution order changed. For now it works so great!
Since I tested the marker editor and got the results I wanted I’m now trying it the clip editor. But I feel like what I’d like to do is simply not possible. I’d like to draw an icon at the start and end position of the clip. The thing is that the icons get cut in half. It seems like I cannot draw outside the clip region…which to be fair makes sense.
Is there a way to draw outside that region?
If not, it’s not a deal breaker I feel like I can still get the point across. If need be I could always shift the icons inside… but I’d prefer the center to be exactly on start and end.
Here is how my custom stuff looks like so far, I’ll just need to swap out the icons and I’m good to go.
Hey! I’m trying to do something simpler but similar (just add a red visual highlight to certain clips), could you share how you got this working on the clip?
I have one issue with the clip custom editor. When I move the timeline cursor the clips are trimmed as they go off view. The issue is that my code depends on the clip background region to draw the icons on the sides. So as I move the timeline along the icons move along the clip instead of staying at the start, center and end of the clip. @julienb I was wondering if you had any hidden trick I could use. I know it should be possible since the text/name of the clip stays in the center always. I can’t seem to find the source code for this though.
I attached below a gif showing the issue.
PS: Also is there a way to hide the clip name? It kinds of hide the icons
I took a good look at our code and unfortunately, I did not find a way to achieve what you want with the current API. Internally, we have the information about the complete clip rect (so we can position the label at the center) but this is not provided in the public API.
Regarding the clip name, you cannot hide it (unless you clear the name of the clip itself, which is kind of ugly I’ll agree).
I’ll add those two things (non-clipped rect + hide display name) to our list of feature requests.
When the clip name is empty it writes “(Empty)” on the clip. So for now as a workaround I automatically set the name to “.” which is the character that is the least noticeable.