// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using FlaxEditor.GUI.Timeline.Tracks;
using FlaxEngine;
namespace FlaxEditor.GUI.Timeline
{
///
/// The timeline editor for animation asset.
///
///
public sealed class AnimationTimeline : Timeline
{
private sealed class Proxy : ProxyBase
{
///
public Proxy(AnimationTimeline timeline)
: base(timeline)
{
}
}
///
/// Initializes a new instance of the class.
///
/// The undo/redo to use for the history actions recording. Optional, can be null to disable undo support.
public AnimationTimeline(FlaxEditor.Undo undo)
: base(PlaybackButtons.None, undo, false, false)
{
PlaybackState = PlaybackStates.Seeking;
ShowPreviewValues = false;
PropertiesEditObject = new Proxy(this);
// Setup track types
TrackArchetypes.Add(AnimationChannelTrack.GetArchetype());
TrackArchetypes.Add(AnimationChannelDataTrack.GetArchetype());
}
///
/// Loads the timeline from the specified asset.
///
/// The asset.
public void Load(Animation asset)
{
Profiler.BeginEvent("Asset.LoadTimeline");
asset.LoadTimeline(out var data);
Profiler.EndEvent();
Profiler.BeginEvent("Timeline.Load");
Load(data);
Profiler.EndEvent();
}
///
/// Saves the timeline data to the asset.
///
/// The asset.
public void Save(Animation asset)
{
var data = Save();
asset.SaveTimeline(data);
asset.Reload();
}
///
public override void OnSeek(int frame)
{
CurrentFrame = frame;
base.OnSeek(frame);
}
}
}