Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,307 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of the on-screen area where a clip is drawn
|
||||
/// </summary>
|
||||
public struct ClipBackgroundRegion
|
||||
{
|
||||
/// <summary>
|
||||
/// The rectangle where the background of the clip is drawn.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The rectangle is clipped to the screen. The rectangle does not include clip borders.
|
||||
/// </remarks>
|
||||
public Rect position { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The start time of the region, relative to the clip.
|
||||
/// </summary>
|
||||
public double startTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The end time of the region, relative to the clip.
|
||||
/// </summary>
|
||||
public double endTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="_position"></param>
|
||||
/// <param name="_startTime"></param>
|
||||
/// <param name="_endTime"></param>
|
||||
public ClipBackgroundRegion(Rect _position, double _startTime, double _endTime)
|
||||
{
|
||||
position = _position;
|
||||
startTime = _startTime;
|
||||
endTime = _endTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance and a specified object are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns>Returns <c>true</c> if <paramref name="obj"/> and this instance are the same type and represent the same value.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ClipBackgroundRegion))
|
||||
return false;
|
||||
|
||||
return Equals((ClipBackgroundRegion)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares this object with another <c>ClipBackgroundRegion</c>.
|
||||
/// </summary>
|
||||
/// <param name="other">The object to compare with.</param>
|
||||
/// <returns>Returns true if <c>this</c> and <paramref name="other"/> are equal.</returns>
|
||||
public bool Equals(ClipBackgroundRegion other)
|
||||
{
|
||||
return position.Equals(other.position) &&
|
||||
startTime == other.startTime &&
|
||||
endTime == other.endTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.CombineHash(
|
||||
position.GetHashCode(),
|
||||
startTime.GetHashCode(),
|
||||
endTime.GetHashCode()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>ClipBackgroundRegion</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="region1">The first object.</param>
|
||||
/// <param name="region2">The second object.</param>
|
||||
/// <returns>Returns true if they are equal.</returns>
|
||||
public static bool operator==(ClipBackgroundRegion region1, ClipBackgroundRegion region2)
|
||||
{
|
||||
return region1.Equals(region2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>ClipBackgroundRegion</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="region1">The first object.</param>
|
||||
/// <param name="region2">The second object.</param>
|
||||
/// <returns>Returns true if they are not equal.</returns>
|
||||
public static bool operator!=(ClipBackgroundRegion region1, ClipBackgroundRegion region2)
|
||||
{
|
||||
return !region1.Equals(region2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The user-defined options for drawing a clip.
|
||||
/// </summary>
|
||||
public struct ClipDrawOptions
|
||||
{
|
||||
private IEnumerable<Texture2D> m_Icons;
|
||||
|
||||
/// <summary>
|
||||
/// Text that indicates if the clip should display an error.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the error text is not empty or null, then the clip displays a warning. The error text is used as the tooltip.
|
||||
/// </remarks>
|
||||
public string errorText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tooltip to show for the clip.
|
||||
/// </summary>
|
||||
public string tooltip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The color drawn under the clip. By default, the color is the same as the track color.
|
||||
/// </summary>
|
||||
public Color highlightColor { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Icons to display on the clip.
|
||||
/// </summary>
|
||||
public IEnumerable<Texture2D> icons
|
||||
{
|
||||
get { return m_Icons ?? System.Linq.Enumerable.Empty<Texture2D>(); }
|
||||
set { m_Icons = value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance and a specified object are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns>Returns <c>true</c> if <paramref name="obj"/> and this instance are the same type and represent the same value.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ClipDrawOptions))
|
||||
return false;
|
||||
|
||||
return Equals((ClipDrawOptions)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares this object with another <c>ClipDrawOptions</c>.
|
||||
/// </summary>
|
||||
/// <param name="other">The object to compare with.</param>
|
||||
/// <returns>Returns true if <c>this</c> and <paramref name="other"/> are equal.</returns>
|
||||
public bool Equals(ClipDrawOptions other)
|
||||
{
|
||||
return errorText == other.errorText &&
|
||||
tooltip == other.tooltip &&
|
||||
highlightColor == other.highlightColor &&
|
||||
System.Linq.Enumerable.SequenceEqual(icons, other.icons);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.CombineHash(
|
||||
errorText != null ? errorText.GetHashCode() : 0,
|
||||
tooltip != null ? tooltip.GetHashCode() : 0,
|
||||
highlightColor.GetHashCode(),
|
||||
icons != null ? icons.GetHashCode() : 0
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>ClipDrawOptions</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="options1">The first object.</param>
|
||||
/// <param name="options2">The second object.</param>
|
||||
/// <returns>Returns true if they are equal.</returns>
|
||||
public static bool operator==(ClipDrawOptions options1, ClipDrawOptions options2)
|
||||
{
|
||||
return options1.Equals(options2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>ClipDrawOptions</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="options1">The first object.</param>
|
||||
/// <param name="options2">The second object.</param>
|
||||
/// <returns>Returns true if they are not equal.</returns>
|
||||
public static bool operator!=(ClipDrawOptions options1, ClipDrawOptions options2)
|
||||
{
|
||||
return !options1.Equals(options2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this class to customize clip types in the TimelineEditor.
|
||||
/// </summary>
|
||||
public class ClipEditor
|
||||
{
|
||||
static readonly string k_NoPlayableAssetError = L10n.Tr("This clip does not contain a valid playable asset");
|
||||
static readonly string k_ScriptLoadError = L10n.Tr("The associated script can not be loaded");
|
||||
|
||||
internal readonly bool supportsSubTimelines;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public ClipEditor()
|
||||
{
|
||||
supportsSubTimelines = TypeUtility.HasOverrideMethod(GetType(), nameof(GetSubTimelines));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method to override the default options for drawing a clip.
|
||||
/// </summary>
|
||||
/// <param name="clip">The clip being drawn.</param>
|
||||
/// <returns>The options for drawing a clip.</returns>
|
||||
public virtual ClipDrawOptions GetClipOptions(TimelineClip clip)
|
||||
{
|
||||
return new ClipDrawOptions()
|
||||
{
|
||||
errorText = GetErrorText(clip),
|
||||
tooltip = string.Empty,
|
||||
highlightColor = GetDefaultHighlightColor(clip),
|
||||
icons = System.Linq.Enumerable.Empty<Texture2D>()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to draw a background for a clip .
|
||||
/// </summary>
|
||||
/// <param name="clip">The clip being drawn.</param>
|
||||
/// <param name="region">The on-screen area where the clip is drawn.</param>
|
||||
public virtual void DrawBackground(TimelineClip clip, ClipBackgroundRegion region)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a clip is created.
|
||||
/// </summary>
|
||||
/// <param name="clip">The newly created clip.</param>
|
||||
/// <param name="track">The track that the clip is assigned to.</param>
|
||||
/// <param name="clonedFrom">The source that the clip was copied from. This can be set to null if the clip is not a copy.</param>
|
||||
/// <remarks>
|
||||
/// The callback occurs before the clip is assigned to the track.
|
||||
/// </remarks>
|
||||
public virtual void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error text for the specified clip.
|
||||
/// </summary>
|
||||
/// <param name="clip">The clip being drawn.</param>
|
||||
/// <returns>Returns the error text to be displayed as the tool tip for the clip. If there is no error to be displayed, this method returns string.Empty.</returns>
|
||||
public string GetErrorText(TimelineClip clip)
|
||||
{
|
||||
if (clip == null || clip.asset == null)
|
||||
return k_NoPlayableAssetError;
|
||||
|
||||
var playableAsset = clip.asset as ScriptableObject;
|
||||
if (playableAsset == null || MonoScript.FromScriptableObject(playableAsset) == null)
|
||||
return k_ScriptLoadError;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color drawn under the clip. By default, the color is the same as the track color.
|
||||
/// </summary>
|
||||
/// <param name="clip">The clip being drawn.</param>
|
||||
/// <returns>Returns the highlight color of the clip being drawn.</returns>
|
||||
public Color GetDefaultHighlightColor(TimelineClip clip)
|
||||
{
|
||||
if (clip == null)
|
||||
return Color.white;
|
||||
|
||||
return TrackResourceCache.GetTrackColor(clip.GetParentTrack());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a clip is changed by the Editor.
|
||||
/// </summary>
|
||||
/// <param name="clip">The clip that changed.</param>
|
||||
public virtual void OnClipChanged(TimelineClip clip)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sub-timelines for a specific clip. Implement this method if your clip supports playing nested timelines.
|
||||
/// </summary>
|
||||
/// <param name="clip">The clip with the ControlPlayableAsset.</param>
|
||||
/// <param name="director">The playable director driving the Timeline Clip. This may not be the same as TimelineEditor.inspectedDirector.</param>
|
||||
/// <param name="subTimelines">Specify the sub-timelines to control.</param>
|
||||
public virtual void GetSubTimelines(TimelineClip clip, PlayableDirector director, List<PlayableDirector> subTimelines)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2537ddddebaa455409dec422eb08fd7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,155 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class CustomTimelineEditorCache
|
||||
{
|
||||
static class SubClassCache<TEditorClass> where TEditorClass : class, new()
|
||||
{
|
||||
private static Type[] s_SubClasses = null;
|
||||
private static readonly TEditorClass s_DefaultInstance = new TEditorClass();
|
||||
private static readonly Dictionary<System.Type, TEditorClass> s_TypeMap = new Dictionary<Type, TEditorClass>();
|
||||
|
||||
public static TEditorClass DefaultInstance
|
||||
{
|
||||
get { return s_DefaultInstance; }
|
||||
}
|
||||
|
||||
static Type[] SubClasses
|
||||
{
|
||||
get
|
||||
{
|
||||
// order the subclass array by built-ins then user defined so built-in classes are chosen first
|
||||
return s_SubClasses ??
|
||||
(s_SubClasses = TypeCache.GetTypesDerivedFrom<TEditorClass>().OrderBy(t => t.Assembly == typeof(UnityEditor.Timeline.TimelineEditor).Assembly ? 1 : 0).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public static TEditorClass GetEditorForType(Type type)
|
||||
{
|
||||
TEditorClass editorClass = null;
|
||||
if (!s_TypeMap.TryGetValue(type, out editorClass) || editorClass == null)
|
||||
{
|
||||
Type editorClassType = null;
|
||||
Type searchType = type;
|
||||
while (searchType != null)
|
||||
{
|
||||
// search our way up the runtime class hierarchy so we get the best match
|
||||
editorClassType = GetExactEditorClassForType(searchType);
|
||||
if (editorClassType != null)
|
||||
break;
|
||||
searchType = searchType.BaseType;
|
||||
}
|
||||
|
||||
if (editorClassType == null)
|
||||
{
|
||||
editorClass = s_DefaultInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
editorClass = (TEditorClass)Activator.CreateInstance(editorClassType);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarningFormat("Could not create a Timeline editor class of type {0}: {1}", editorClassType, e.Message);
|
||||
editorClass = s_DefaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
s_TypeMap[type] = editorClass;
|
||||
}
|
||||
|
||||
return editorClass;
|
||||
}
|
||||
|
||||
private static Type GetExactEditorClassForType(Type type)
|
||||
{
|
||||
foreach (var subClass in SubClasses)
|
||||
{
|
||||
// first check for exact match
|
||||
var attr = (CustomTimelineEditorAttribute)Attribute.GetCustomAttribute(subClass, typeof(CustomTimelineEditorAttribute), false);
|
||||
if (attr != null && attr.classToEdit == type)
|
||||
{
|
||||
return subClass;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
s_TypeMap.Clear();
|
||||
s_SubClasses = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static TEditorClass GetEditorForType<TEditorClass, TRuntimeClass>(Type type) where TEditorClass : class, new()
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
if (!typeof(TRuntimeClass).IsAssignableFrom(type))
|
||||
throw new ArgumentException(type.FullName + " does not inherit from" + typeof(TRuntimeClass));
|
||||
|
||||
return SubClassCache<TEditorClass>.GetEditorForType(type);
|
||||
}
|
||||
|
||||
public static void ClearCache<TEditorClass>() where TEditorClass : class, new()
|
||||
{
|
||||
SubClassCache<TEditorClass>.Clear();
|
||||
}
|
||||
|
||||
public static ClipEditor GetClipEditor(TimelineClip clip)
|
||||
{
|
||||
if (clip == null)
|
||||
throw new ArgumentNullException(nameof(clip));
|
||||
|
||||
var type = typeof(IPlayableAsset);
|
||||
if (clip.asset != null)
|
||||
type = clip.asset.GetType();
|
||||
|
||||
if (!typeof(IPlayableAsset).IsAssignableFrom(type))
|
||||
return GetDefaultClipEditor();
|
||||
|
||||
return GetEditorForType<ClipEditor, IPlayableAsset>(type);
|
||||
}
|
||||
|
||||
public static ClipEditor GetDefaultClipEditor()
|
||||
{
|
||||
return SubClassCache<ClipEditor>.DefaultInstance;
|
||||
}
|
||||
|
||||
public static TrackEditor GetTrackEditor(TrackAsset track)
|
||||
{
|
||||
if (track == null)
|
||||
throw new ArgumentNullException(nameof(track));
|
||||
|
||||
return GetEditorForType<TrackEditor, TrackAsset>(track.GetType());
|
||||
}
|
||||
|
||||
public static TrackEditor GetDefaultTrackEditor()
|
||||
{
|
||||
return SubClassCache<TrackEditor>.DefaultInstance;
|
||||
}
|
||||
|
||||
public static MarkerEditor GetMarkerEditor(IMarker marker)
|
||||
{
|
||||
if (marker == null)
|
||||
throw new ArgumentNullException(nameof(marker));
|
||||
return GetEditorForType<MarkerEditor, IMarker>(marker.GetType());
|
||||
}
|
||||
|
||||
public static MarkerEditor GetDefaultMarkerEditor()
|
||||
{
|
||||
return SubClassCache<MarkerEditor>.DefaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd6ede1d2f47ab146b2ec0a3969a37cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,292 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
/// <summary>
|
||||
/// The flags that indicate the view status of a marker.
|
||||
/// </summary>
|
||||
[System.Flags]
|
||||
public enum MarkerUIStates
|
||||
{
|
||||
/// <summary>
|
||||
/// No extra state specified.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The marker is selected.
|
||||
/// </summary>
|
||||
Selected = 1 << 0,
|
||||
|
||||
/// <summary>
|
||||
/// The marker is in a collapsed state.
|
||||
/// </summary>
|
||||
Collapsed = 1 << 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The user-defined options for drawing a marker.
|
||||
/// </summary>
|
||||
public struct MarkerDrawOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The tooltip for the marker.
|
||||
/// </summary>
|
||||
public string tooltip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Text that indicates if the marker should display an error.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the error text is not empty or null, then the marker displays a warning. The error text is used as the tooltip.
|
||||
/// </remarks>
|
||||
public string errorText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance and a specified object are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns>Returns <c>true</c> if <paramref name="obj"/> and this instance are the same type and represent the same value.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is MarkerDrawOptions))
|
||||
return false;
|
||||
|
||||
return Equals((MarkerDrawOptions)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares this object with another <c>MarkerDrawOptions</c>.
|
||||
/// </summary>
|
||||
/// <param name="other">The object to compare with.</param>
|
||||
/// <returns>Returns true if <c>this</c> and <paramref name="other"/> are equal.</returns>
|
||||
public bool Equals(MarkerDrawOptions other)
|
||||
{
|
||||
return errorText == other.errorText &&
|
||||
tooltip == other.tooltip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.CombineHash(
|
||||
errorText != null ? errorText.GetHashCode() : 0,
|
||||
tooltip != null ? tooltip.GetHashCode() : 0
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>MarkerDrawOptions</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="options1">The first object.</param>
|
||||
/// <param name="options2">The second object.</param>
|
||||
/// <returns>Returns true if they are equal.</returns>
|
||||
public static bool operator==(MarkerDrawOptions options1, MarkerDrawOptions options2)
|
||||
{
|
||||
return options1.Equals(options2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>MarkerDrawOptions</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="options1">The first object.</param>
|
||||
/// <param name="options2">The second object.</param>
|
||||
/// <returns>Returns true if they are not equal.</returns>
|
||||
public static bool operator!=(MarkerDrawOptions options1, MarkerDrawOptions options2)
|
||||
{
|
||||
return !options1.Equals(options2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The description of the on-screen area where the marker is drawn.
|
||||
/// </summary>
|
||||
public struct MarkerOverlayRegion
|
||||
{
|
||||
/// <summary>
|
||||
/// The area where the marker is being drawn.
|
||||
/// </summary>
|
||||
public Rect markerRegion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The area where the overlay is being drawn.
|
||||
///
|
||||
/// This region extends from the top of the time ruler to the bottom of the window, excluding any scrollbars.
|
||||
/// </summary>
|
||||
public Rect timelineRegion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sub-area of the timelineRegion where the tracks are drawn.
|
||||
///
|
||||
/// The region extends from the bottom of the time ruler, or the timeline marker region if not hidden.
|
||||
/// Use this region to clip overlays that should not be drawn over the timeline marker region or time ruler.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// <code source="../../DocCodeExamples/MarkerEditorExamples.cs" region="declare-trackRegion" title="trackRegion"/>
|
||||
/// </example>
|
||||
public Rect trackRegion => Rect.MinMaxRect(timelineRegion.xMin, timelineRegion.yMin + m_TrackOffset, timelineRegion.xMax, timelineRegion.yMax);
|
||||
|
||||
/// <summary>
|
||||
/// The start time of the visible region of the window.
|
||||
/// </summary>
|
||||
public double startTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The end time of the visible region of the window.
|
||||
/// </summary>
|
||||
public double endTime { get; private set; }
|
||||
|
||||
private float m_TrackOffset;
|
||||
|
||||
/// <summary>Constructor</summary>
|
||||
/// <param name="_markerRegion">The area where the marker is being drawn.</param>
|
||||
/// <param name="_timelineRegion">The area where the overlay is being drawn.</param>
|
||||
/// <param name="_startTime">The start time of the visible region of the window.</param>
|
||||
/// <param name="_endTime">The end time of the visible region of the window.</param>
|
||||
public MarkerOverlayRegion(Rect _markerRegion, Rect _timelineRegion, double _startTime, double _endTime)
|
||||
: this(_markerRegion, _timelineRegion, _startTime, _endTime, 19.0f)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Constructor</summary>
|
||||
/// <param name="_markerRegion">The area where the marker is being drawn.</param>
|
||||
/// <param name="_timelineRegion">The area where the overlay is being drawn.</param>
|
||||
/// <param name="_startTime">The start time of the visible region of the window.</param>
|
||||
/// <param name="_endTime">The end time of the visible region of the window.</param>
|
||||
/// <param name="_trackOffset">The offset from the timelineRegion to the trackRegion</param>
|
||||
public MarkerOverlayRegion(Rect _markerRegion, Rect _timelineRegion, double _startTime, double _endTime, float _trackOffset)
|
||||
{
|
||||
markerRegion = _markerRegion;
|
||||
timelineRegion = _timelineRegion;
|
||||
startTime = _startTime;
|
||||
endTime = _endTime;
|
||||
m_TrackOffset = _trackOffset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance and a specified object are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns>Returns <c>true</c> if <paramref name="obj"/> and this instance are the same type and represent the same value.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is MarkerOverlayRegion))
|
||||
return false;
|
||||
|
||||
return Equals((MarkerOverlayRegion)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares this object with another <c>MarkerOverlayRegion</c>.
|
||||
/// </summary>
|
||||
/// <param name="other">The object to compare with.</param>
|
||||
/// <returns>Returns true if <c>this</c> and <paramref name="other"/> are equal.</returns>
|
||||
public bool Equals(MarkerOverlayRegion other)
|
||||
{
|
||||
return markerRegion == other.markerRegion &&
|
||||
timelineRegion == other.timelineRegion &&
|
||||
startTime == other.startTime &&
|
||||
endTime == other.endTime &&
|
||||
m_TrackOffset == other.m_TrackOffset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.CombineHash(
|
||||
markerRegion.GetHashCode(),
|
||||
timelineRegion.GetHashCode(),
|
||||
startTime.GetHashCode(),
|
||||
endTime.GetHashCode(),
|
||||
m_TrackOffset.GetHashCode()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>MarkerOverlayRegion</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="region1">The first object.</param>
|
||||
/// <param name="region2">The second object.</param>
|
||||
/// <returns>Returns true if they are equal.</returns>
|
||||
public static bool operator==(MarkerOverlayRegion region1, MarkerOverlayRegion region2)
|
||||
{
|
||||
return region1.Equals(region2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>MarkerOverlayRegion</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="region1">The first object.</param>
|
||||
/// <param name="region2">The second object.</param>
|
||||
/// <returns>Returns true if they are not equal.</returns>
|
||||
public static bool operator!=(MarkerOverlayRegion region1, MarkerOverlayRegion region2)
|
||||
{
|
||||
return !region1.Equals(region2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this class to customize marker types in the TimelineEditor.
|
||||
/// </summary>
|
||||
public class MarkerEditor
|
||||
{
|
||||
internal readonly bool supportsDrawOverlay;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public MarkerEditor()
|
||||
{
|
||||
supportsDrawOverlay = TypeUtility.HasOverrideMethod(GetType(), nameof(DrawOverlay));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method to override the default options for drawing a marker.
|
||||
/// </summary>
|
||||
/// <param name="marker">The marker to draw.</param>
|
||||
/// <returns></returns>
|
||||
public virtual MarkerDrawOptions GetMarkerOptions(IMarker marker)
|
||||
{
|
||||
return new MarkerDrawOptions()
|
||||
{
|
||||
tooltip = string.Empty,
|
||||
errorText = string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a marker is created.
|
||||
/// </summary>
|
||||
/// <param name="marker">The marker that is created.</param>
|
||||
/// <param name="clonedFrom">TThe source that the marker was copied from. This can be set to null if the marker is not a copy.</param>
|
||||
/// <remarks>
|
||||
/// The callback occurs before the marker is assigned to the track.
|
||||
/// </remarks>
|
||||
public virtual void OnCreate(IMarker marker, IMarker clonedFrom)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws additional overlays for a marker.
|
||||
/// </summary>
|
||||
/// <param name="marker">The marker to draw.</param>
|
||||
/// <param name="uiState">The visual state of the marker.</param>
|
||||
/// <param name="region">The on-screen area where the marker is being drawn.</param>
|
||||
/// <remarks>
|
||||
/// Notes:
|
||||
/// * It is only called during TimelineWindow's Repaint step.
|
||||
/// * If there are multiple markers on top of each other, only the topmost marker receives the DrawOverlay call.
|
||||
/// </remarks>
|
||||
public virtual void DrawOverlay(IMarker marker, MarkerUIStates uiState, MarkerOverlayRegion region)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 99c5970046bb263469514e56eb6aa519
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
[CustomTimelineEditor(typeof(MarkerTrack))]
|
||||
class MarkerTrackEditor : TrackEditor
|
||||
{
|
||||
public static readonly float DefaultMarkerTrackHeight = 24;
|
||||
|
||||
public override TrackDrawOptions GetTrackOptions(TrackAsset track, Object binding)
|
||||
{
|
||||
var options = base.GetTrackOptions(track, binding);
|
||||
options.minimumHeight = DefaultMarkerTrackHeight;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 844873d1afe1c3142ab922324950e1dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,417 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
/// <summary>
|
||||
/// The user-defined options for drawing a track."
|
||||
/// </summary>
|
||||
public struct TrackDrawOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Text that indicates if the track should display an error.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the error text is not empty or null, then the track displays a warning. The error text is used as the tooltip.
|
||||
/// </remarks>
|
||||
public string errorText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The highlight color of the track.
|
||||
/// </summary>
|
||||
public Color trackColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The minimum height of the track.
|
||||
/// </summary>
|
||||
public float minimumHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The icon displayed on the track header.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If this value is null, then the default icon for the track is used.
|
||||
/// </remarks>
|
||||
public Texture2D icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance and a specified object are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current instance.</param>
|
||||
/// <returns>Returns <c>true</c> if <paramref name="obj"/> and this instance are the same type and represent the same value.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is TrackDrawOptions))
|
||||
return false;
|
||||
|
||||
return Equals((TrackDrawOptions)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares this object with another <c>TrackDrawOptions</c>.
|
||||
/// </summary>
|
||||
/// <param name="other">The object to compare with.</param>
|
||||
/// <returns>Returns true if <c>this</c> and <paramref name="other"/> are equal.</returns>
|
||||
public bool Equals(TrackDrawOptions other)
|
||||
{
|
||||
return errorText == other.errorText &&
|
||||
trackColor == other.trackColor &&
|
||||
minimumHeight == other.minimumHeight &&
|
||||
icon == other.icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.CombineHash(
|
||||
errorText != null ? errorText.GetHashCode() : 0,
|
||||
trackColor.GetHashCode(),
|
||||
minimumHeight.GetHashCode(),
|
||||
icon != null ? icon.GetHashCode() : 0
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>TrackDrawOptions</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="options1">The first object.</param>
|
||||
/// <param name="options2">The second object.</param>
|
||||
/// <returns>Returns true if they are equal.</returns>
|
||||
public static bool operator==(TrackDrawOptions options1, TrackDrawOptions options2)
|
||||
{
|
||||
return options1.Equals(options2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <c>TrackDrawOptions</c> objects.
|
||||
/// </summary>
|
||||
/// <param name="options1">The first object.</param>
|
||||
/// <param name="options2">The second object.</param>
|
||||
/// <returns>Returns true if they are not equal.</returns>
|
||||
public static bool operator!=(TrackDrawOptions options1, TrackDrawOptions options2)
|
||||
{
|
||||
return !options1.Equals(options2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The errors displayed for the track binding.
|
||||
/// </summary>
|
||||
public enum TrackBindingErrors
|
||||
{
|
||||
/// <summary>
|
||||
/// Select no errors.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The bound GameObject is disabled.
|
||||
/// </summary>
|
||||
BoundGameObjectDisabled = 1 << 0,
|
||||
|
||||
/// <summary>
|
||||
/// The bound GameObject does not have a valid component.
|
||||
/// </summary>
|
||||
NoValidComponent = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// The bound Object is a disabled Behaviour.
|
||||
/// </summary>
|
||||
BehaviourIsDisabled = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// The bound Object is not of the correct type.
|
||||
/// </summary>
|
||||
InvalidBinding = 1 << 3,
|
||||
|
||||
/// <summary>
|
||||
/// The bound Object is part of a prefab, and not an instance.
|
||||
/// </summary>
|
||||
PrefabBound = 1 << 4,
|
||||
|
||||
/// <summary>
|
||||
/// Select all errors.
|
||||
/// </summary>
|
||||
All = Int32.MaxValue
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this class to customize track types in the TimelineEditor.
|
||||
/// </summary>
|
||||
public class TrackEditor
|
||||
{
|
||||
static readonly string k_BoundGameObjectDisabled = L10n.Tr("The bound GameObject is disabled.");
|
||||
static readonly string k_NoValidComponent = L10n.Tr("Could not find appropriate component on this gameObject");
|
||||
static readonly string k_RequiredComponentIsDisabled = L10n.Tr("The component is disabled");
|
||||
static readonly string k_InvalidBinding = L10n.Tr("The bound object is not the correct type.");
|
||||
static readonly string k_PrefabBound = L10n.Tr("The bound object is a Prefab");
|
||||
|
||||
readonly Dictionary<TrackAsset, System.Type> m_BindingCache = new Dictionary<TrackAsset, System.Type>();
|
||||
|
||||
/// <summary>
|
||||
/// The default height of a track.
|
||||
/// </summary>
|
||||
public static readonly float DefaultTrackHeight = 30.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum unscaled height of a track.
|
||||
/// </summary>
|
||||
public static readonly float MinimumTrackHeight = 10.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum height of a track.
|
||||
/// </summary>
|
||||
public static readonly float MaximumTrackHeight = 256.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method to override the default options for drawing a track.
|
||||
/// </summary>
|
||||
/// <param name="track">The track from which track options are retrieved.</param>
|
||||
/// <param name="binding">The binding for the track.</param>
|
||||
/// <returns>The options for drawing the track.</returns>
|
||||
public virtual TrackDrawOptions GetTrackOptions(TrackAsset track, UnityEngine.Object binding)
|
||||
{
|
||||
return new TrackDrawOptions()
|
||||
{
|
||||
errorText = GetErrorText(track, binding, TrackBindingErrors.All),
|
||||
minimumHeight = DefaultTrackHeight,
|
||||
trackColor = GetTrackColor(track),
|
||||
icon = null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error text for the specified track.
|
||||
/// </summary>
|
||||
/// <param name="track">The track to retrieve options for.</param>
|
||||
/// <param name="boundObject">The binding for the track.</param>
|
||||
/// <param name="detectErrors">The errors to check for.</param>
|
||||
/// <returns>An error to be displayed on the track, or string.Empty if there is no error.</returns>
|
||||
public string GetErrorText(TrackAsset track, UnityEngine.Object boundObject, TrackBindingErrors detectErrors)
|
||||
{
|
||||
if (track == null || boundObject == null)
|
||||
return string.Empty;
|
||||
|
||||
var bindingType = GetBindingType(track);
|
||||
if (bindingType != null)
|
||||
{
|
||||
// bound to a prefab asset
|
||||
if (HasFlag(detectErrors, TrackBindingErrors.PrefabBound) && PrefabUtility.IsPartOfPrefabAsset(boundObject))
|
||||
{
|
||||
return k_PrefabBound;
|
||||
}
|
||||
|
||||
// If we are a component, allow for bound game objects (legacy)
|
||||
if (typeof(Component).IsAssignableFrom(bindingType))
|
||||
{
|
||||
var gameObject = boundObject as GameObject;
|
||||
var component = boundObject as Component;
|
||||
if (component != null)
|
||||
gameObject = component.gameObject;
|
||||
|
||||
// game object is bound with no component
|
||||
if (HasFlag(detectErrors, TrackBindingErrors.NoValidComponent) && gameObject != null && component == null)
|
||||
{
|
||||
component = gameObject.GetComponent(bindingType);
|
||||
if (component == null)
|
||||
{
|
||||
return k_NoValidComponent;
|
||||
}
|
||||
}
|
||||
|
||||
// attached gameObject is disables (ignores Activation Track)
|
||||
if (HasFlag(detectErrors, TrackBindingErrors.BoundGameObjectDisabled) && gameObject != null && !gameObject.activeInHierarchy)
|
||||
{
|
||||
return k_BoundGameObjectDisabled;
|
||||
}
|
||||
|
||||
// component is disabled
|
||||
var behaviour = component as Behaviour;
|
||||
if (HasFlag(detectErrors, TrackBindingErrors.BehaviourIsDisabled) && behaviour != null && !behaviour.enabled)
|
||||
{
|
||||
return k_RequiredComponentIsDisabled;
|
||||
}
|
||||
|
||||
// mismatched binding
|
||||
if (HasFlag(detectErrors, TrackBindingErrors.InvalidBinding) && component != null && !bindingType.IsAssignableFrom(component.GetType()))
|
||||
{
|
||||
return k_InvalidBinding;
|
||||
}
|
||||
}
|
||||
// Mismatched binding (non-component)
|
||||
else if (HasFlag(detectErrors, TrackBindingErrors.InvalidBinding) && !bindingType.IsAssignableFrom(boundObject.GetType()))
|
||||
{
|
||||
return k_InvalidBinding;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color information of a track.
|
||||
/// </summary>
|
||||
/// <param name="track"></param>
|
||||
/// <returns>Returns the color for the specified track.</returns>
|
||||
public Color GetTrackColor(TrackAsset track)
|
||||
{
|
||||
return TrackResourceCache.GetTrackColor(track);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the binding type for a track.
|
||||
/// </summary>
|
||||
/// <param name="track">The track to retrieve the binding type from.</param>
|
||||
/// <returns>Returns the binding type for the specified track. Returns null if the track does not have binding.</returns>
|
||||
public System.Type GetBindingType(TrackAsset track)
|
||||
{
|
||||
if (track == null)
|
||||
return null;
|
||||
|
||||
if (m_BindingCache.TryGetValue(track, out var result))
|
||||
return result;
|
||||
|
||||
result = track.outputs.Select(x => x.outputTargetType).FirstOrDefault();
|
||||
m_BindingCache[track] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when a track is created.
|
||||
/// </summary>
|
||||
/// <param name="track">The track that is created.</param>
|
||||
/// <param name="copiedFrom">The source that the track is copied from. This can be set to null if the track is not a copy.</param>
|
||||
public virtual void OnCreate(TrackAsset track, TrackAsset copiedFrom)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when a track is changed.
|
||||
/// </summary>
|
||||
/// <param name="track">The track that is changed.</param>
|
||||
public virtual void OnTrackChanged(TrackAsset track)
|
||||
{
|
||||
}
|
||||
|
||||
static bool HasFlag(TrackBindingErrors errors, TrackBindingErrors flag)
|
||||
{
|
||||
return (errors & flag) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to validate if a binding for <paramref name="track"/>
|
||||
/// can be determined from <paramref name="candidate"/>.
|
||||
///
|
||||
/// The default implementation of this method will return true if
|
||||
/// - <paramref name="candidate"/> is not null or,
|
||||
/// - <paramref name="candidate"/> is not part of a Prefab Asset or,
|
||||
/// - <paramref name="candidate"/> is a Component that can be bound to <paramref name="track"/>
|
||||
/// </summary>
|
||||
/// <param name="candidate"></param>
|
||||
/// <param name="track">TBD</param>
|
||||
/// <returns>True if a binding can be determined from <paramref name="candidate"/>.</returns>
|
||||
/// <seealso cref="UnityEngine.Timeline.TrackBindingTypeAttribute"/>
|
||||
/// <seealso cref="UnityEngine.Timeline.TrackAsset"/>
|
||||
public virtual bool IsBindingAssignableFrom(UnityEngine.Object candidate, TrackAsset track)
|
||||
{
|
||||
var action = BindingUtility.GetBindingAction(GetBindingType(track), candidate);
|
||||
return action != BindingUtility.BindingAction.DoNotBind;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to determine which object to bind to <paramref name="track"/>.
|
||||
/// A binding object should be determined from <paramref name="candidate"/>.
|
||||
///
|
||||
/// By default, the `TrackBindingType` attribute from <paramref name="track"/> will be used to determine the binding.
|
||||
/// </summary>
|
||||
/// <param name="candidate">The source object from which a track binding should be determined.</param>
|
||||
/// <param name="track">The track to bind an object to.</param>
|
||||
/// <returns>The object to bind to <paramref name="track"/>.</returns>
|
||||
/// <seealso cref="UnityEngine.Timeline.TrackBindingTypeAttribute"/>
|
||||
/// <seealso cref="UnityEngine.Timeline.TrackAsset"/>
|
||||
public virtual UnityEngine.Object GetBindingFrom(UnityEngine.Object candidate, TrackAsset track)
|
||||
{
|
||||
Type bindingType = GetBindingType(track);
|
||||
BindingUtility.BindingAction action = BindingUtility.GetBindingAction(bindingType, candidate);
|
||||
return BindingUtility.GetBinding(action, candidate, bindingType);
|
||||
}
|
||||
}
|
||||
|
||||
static class TrackEditorExtension
|
||||
{
|
||||
public static bool SupportsBindingAssign(this TrackEditor editor)
|
||||
{
|
||||
return TypeUtility.HasOverrideMethod(editor.GetType(), nameof(TrackEditor.GetBindingFrom));
|
||||
}
|
||||
|
||||
public static void OnCreate_Safe(this TrackEditor editor, TrackAsset track, TrackAsset copiedFrom)
|
||||
{
|
||||
try
|
||||
{
|
||||
editor.OnCreate(track, copiedFrom);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static TrackDrawOptions GetTrackOptions_Safe(this TrackEditor editor, TrackAsset track, UnityEngine.Object binding)
|
||||
{
|
||||
try
|
||||
{
|
||||
return editor.GetTrackOptions(track, binding);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
return CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, binding);
|
||||
}
|
||||
}
|
||||
|
||||
public static UnityEngine.Object GetBindingFrom_Safe(this TrackEditor editor, UnityEngine.Object candidate, TrackAsset track)
|
||||
{
|
||||
try
|
||||
{
|
||||
return editor.GetBindingFrom(candidate, track);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBindingAssignableFrom_Safe(this TrackEditor editor, UnityEngine.Object candidate, TrackAsset track)
|
||||
{
|
||||
try
|
||||
{
|
||||
return editor.IsBindingAssignableFrom(candidate, track);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnTrackChanged_Safe(this TrackEditor editor, TrackAsset track)
|
||||
{
|
||||
try
|
||||
{
|
||||
editor.OnTrackChanged(track);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 35cb34351b19cf44ba78afbd58746610
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue