using UnityEngine.Formats.Alembic.Importer;
using UnityEngine.Playables;
using UnityEngine.Timeline;
namespace UnityEngine.Formats.Alembic.Timeline
{
///
/// Clip representing the playback range of an Alembic asset.
///
[System.ComponentModel.DisplayName("Alembic Shot")]
public class AlembicShotAsset : PlayableAsset, ITimelineClipAsset, IPropertyPreview
{
AlembicStreamPlayer m_stream;
[Tooltip("Alembic asset to play")]
[SerializeField]
private ExposedReference streamPlayer;
ClipCaps ITimelineClipAsset.clipCaps { get { return ClipCaps.Extrapolation | ClipCaps.Looping | ClipCaps.SpeedMultiplier | ClipCaps.ClipIn; } }
///
/// The AlembicStreamPlayer to play.
///
public ExposedReference StreamPlayer
{
get { return streamPlayer; }
set { streamPlayer = value; }
}
///
/// For more information see: https://docs.unity3d.com/ScriptReference/Playables.PlayableAsset.CreatePlayable.html
///
/// The Playable Graph.
/// The GameObject containing the PlayableDirector.
/// The playable that drives the AlembicStreamPlayer.
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable.Create(graph);
var behaviour = playable.GetBehaviour();
m_stream = StreamPlayer.Resolve(graph.GetResolver());
behaviour.streamPlayer = m_stream;
return playable;
}
///
/// Returns the duration selected through the AlembicStreamPlayer.
///
public override double duration
{
get
{
return m_stream == null ? 0 : m_stream.Duration;
}
}
///
public void GatherProperties(PlayableDirector director, IPropertyCollector driver)
{
var streamComponent = streamPlayer.Resolve(director);
if (streamComponent != null)
{
driver.AddFromName(streamComponent.gameObject, "currentTime");
}
}
}
}