diff options
Diffstat (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors')
10 files changed, 0 insertions, 977 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/ClipEditor.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/ClipEditor.cs deleted file mode 100644 index 9f133a1..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/ClipEditor.cs +++ /dev/null @@ -1,256 +0,0 @@ -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; - } - - public override bool Equals(object obj) - { - if (!(obj is ClipBackgroundRegion)) - return false; - - return Equals((ClipBackgroundRegion)obj); - } - - public bool Equals(ClipBackgroundRegion other) - { - return position.Equals(other.position) && - startTime == other.startTime && - endTime == other.endTime; - } - - public override int GetHashCode() - { - return HashUtility.CombineHash( - position.GetHashCode(), - startTime.GetHashCode(), - endTime.GetHashCode() - ); - } - - public static bool operator==(ClipBackgroundRegion region1, ClipBackgroundRegion region2) - { - return region1.Equals(region2); - } - - 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;} - } - - public override bool Equals(object obj) - { - if (!(obj is ClipDrawOptions)) - return false; - - return Equals((ClipDrawOptions)obj); - } - - public bool Equals(ClipDrawOptions other) - { - return errorText == other.errorText && - tooltip == other.tooltip && - highlightColor == other.highlightColor && - System.Linq.Enumerable.SequenceEqual(icons, other.icons); - } - - public override int GetHashCode() - { - return HashUtility.CombineHash( - errorText != null ? errorText.GetHashCode() : 0, - tooltip != null ? tooltip.GetHashCode() : 0, - highlightColor.GetHashCode(), - icons != null ? icons.GetHashCode() : 0 - ); - } - - public static bool operator==(ClipDrawOptions options1, ClipDrawOptions options2) - { - return options1.Equals(options2); - } - - 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 = LocalizationDatabase.GetLocalizedString("This clip does not contain a valid playable asset"); - static readonly string k_ScriptLoadError = LocalizationDatabase.GetLocalizedString("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.parentTrack); - } - - /// <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) - { - } - } -} diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/ClipEditor.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/ClipEditor.cs.meta deleted file mode 100644 index da1b7b5..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/ClipEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2537ddddebaa455409dec422eb08fd7e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/CustomTimelineEditorCache.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/CustomTimelineEditorCache.cs deleted file mode 100644 index 8211a98..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/CustomTimelineEditorCache.cs +++ /dev/null @@ -1,155 +0,0 @@ -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; - } - } -} diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/CustomTimelineEditorCache.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/CustomTimelineEditorCache.cs.meta deleted file mode 100644 index 03cae8e..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/CustomTimelineEditorCache.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fd6ede1d2f47ab146b2ec0a3969a37cc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerEditor.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerEditor.cs deleted file mode 100644 index c0cf995..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerEditor.cs +++ /dev/null @@ -1,209 +0,0 @@ -using UnityEngine; -using UnityEditor.Timeline; -using UnityEngine.Playables; -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; } - - public override bool Equals(object obj) - { - if (!(obj is MarkerDrawOptions)) - return false; - - return Equals((MarkerDrawOptions)obj); - } - - public bool Equals(MarkerDrawOptions other) - { - return errorText == other.errorText && - tooltip == other.tooltip; - } - - public override int GetHashCode() - { - return HashUtility.CombineHash( - errorText != null ? errorText.GetHashCode() : 0, - tooltip != null ? tooltip.GetHashCode() : 0 - ); - } - - public static bool operator==(MarkerDrawOptions options1, MarkerDrawOptions options2) - { - return options1.Equals(options2); - } - - 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> - /// TThe area where the overlay is being drawn. - /// </summary> - public Rect timelineRegion { get; private set; } - - /// <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; } - - /// <summary>Constructor</summary> - public MarkerOverlayRegion(Rect _markerRegion, Rect _timelineRegion, double _startTime, double _endTime) - { - markerRegion = _markerRegion; - timelineRegion = _timelineRegion; - startTime = _startTime; - endTime = _endTime; - } - - public override bool Equals(object obj) - { - if (!(obj is MarkerOverlayRegion)) - return false; - - return Equals((MarkerOverlayRegion)obj); - } - - public bool Equals(MarkerOverlayRegion other) - { - return markerRegion == other.markerRegion && - timelineRegion == other.timelineRegion && - startTime == other.startTime && - endTime == other.endTime; - } - - public override int GetHashCode() - { - return HashUtility.CombineHash( - markerRegion.GetHashCode(), - timelineRegion.GetHashCode(), - startTime.GetHashCode(), - endTime.GetHashCode() - ); - } - - public static bool operator==(MarkerOverlayRegion region1, MarkerOverlayRegion region2) - { - return region1.Equals(region2); - } - - 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) - { - } - } -} diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerEditor.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerEditor.cs.meta deleted file mode 100644 index 7cbab44..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 99c5970046bb263469514e56eb6aa519 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerTrackEditor.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerTrackEditor.cs deleted file mode 100644 index e6e06fb..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerTrackEditor.cs +++ /dev/null @@ -1,18 +0,0 @@ -using UnityEngine; -using UnityEngine.Timeline; - -namespace UnityEditor.Timeline -{ - [CustomTimelineEditor(typeof(MarkerTrack))] - class MarkerTrackEditor : TrackEditor - { - public static readonly float DefaultMarkerTrackHeight = 20; - - public override TrackDrawOptions GetTrackOptions(TrackAsset track, Object binding) - { - var options = base.GetTrackOptions(track, binding); - options.minimumHeight = DefaultMarkerTrackHeight; - return options; - } - } -} diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerTrackEditor.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerTrackEditor.cs.meta deleted file mode 100644 index 5c4b7a9..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/MarkerTrackEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 844873d1afe1c3142ab922324950e1dd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/TrackEditor.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/TrackEditor.cs deleted file mode 100644 index cd4f67c..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/TrackEditor.cs +++ /dev/null @@ -1,284 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Playables; -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; } - - public override bool Equals(object obj) - { - if (!(obj is TrackDrawOptions)) - return false; - - return Equals((TrackDrawOptions)obj); - } - - public bool Equals(TrackDrawOptions other) - { - return errorText == other.errorText && - trackColor == other.trackColor && - minimumHeight == other.minimumHeight && - icon == other.icon; - } - - public override int GetHashCode() - { - return HashUtility.CombineHash( - errorText != null ? errorText.GetHashCode() : 0, - trackColor.GetHashCode(), - minimumHeight.GetHashCode(), - icon != null ? icon.GetHashCode() : 0 - ); - } - - public static bool operator==(TrackDrawOptions options1, TrackDrawOptions options2) - { - return options1.Equals(options2); - } - - 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 = LocalizationDatabase.GetLocalizedString("The bound GameObject is disabled."); - static readonly string k_NoValidComponent = LocalizationDatabase.GetLocalizedString("Could not find appropriate component on this gameObject"); - static readonly string k_RequiredComponentIsDisabled = LocalizationDatabase.GetLocalizedString("The component is disabled"); - static readonly string k_InvalidBinding = LocalizationDatabase.GetLocalizedString("The bound object is not the correct type."); - static readonly string k_PrefabBound = LocalizationDatabase.GetLocalizedString("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; - - System.Type result = null; - if (m_BindingCache.TryGetValue(track, out 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) - { - } - - private static bool HasFlag(TrackBindingErrors errors, TrackBindingErrors flag) - { - return (errors & flag) != 0; - } - } -} diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/TrackEditor.cs.meta b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/TrackEditor.cs.meta deleted file mode 100644 index a7ae571..0000000 --- a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/CustomEditors/TrackEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 35cb34351b19cf44ba78afbd58746610 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: |
