File size: 7,909 Bytes
18a519f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | using System;
using UnityEngine;
namespace UnityEngine.Timeline
{
/// <summary>
/// Specifies the type of PlayableAsset that a TrackAsset derived class can create clips of.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class TrackClipTypeAttribute : Attribute
{
/// <summary>
/// The type of the clip class associate with this track
/// </summary>
public readonly Type inspectedType;
/// <summary>
/// Whether to allow automatic creation of these types.
/// </summary>
public readonly bool allowAutoCreate; // true will make it show up in menus
/// <summary>
/// </summary>
/// <param name="clipClass">The type of the clip class to associate with this track. Must derive from PlayableAsset.</param>
public TrackClipTypeAttribute(Type clipClass)
{
inspectedType = clipClass;
allowAutoCreate = true;
}
/// <summary>
/// </summary>
/// <param name="clipClass">The type of the clip class to associate with this track. Must derive from PlayableAsset.</param>
/// <param name="allowAutoCreate">Whether to allow automatic creation of these types. Default value is true.</param>
/// <remarks>Setting allowAutoCreate to false will cause Timeline to not show menu items for creating clips of this type.</remarks>
public TrackClipTypeAttribute(Type clipClass, bool allowAutoCreate)
{
inspectedType = clipClass;
allowAutoCreate = false;
}
}
/// <summary>
/// Apply this to a PlayableBehaviour class or field to indicate that it is not animatable.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class)]
public class NotKeyableAttribute : Attribute
{
}
/// <summary>
/// Options for track binding
/// </summary>
[Flags]
public enum TrackBindingFlags
{
/// <summary>
/// No options specified
/// </summary>
None = 0,
/// <summary>
/// Allow automatic creating of component during gameObject drag and drop
/// </summary>
AllowCreateComponent = 1,
/// <summary>
/// All options specified
/// </summary>
All = AllowCreateComponent
}
/// <summary>
/// Specifies the type of object that should be bound to a TrackAsset.
/// </summary>
/// <example>
/// <code source="../DocCodeExamples/TimelineAttributesExamples.cs" region="declare-sampleTrackBindingAttr" title="SampleTrackBindingAttr"/>
/// </example>
/// <remarks>
/// Use this attribute when creating Custom Tracks to specify the type of object the track requires a binding to.
/// </remarks>
[AttributeUsage(AttributeTargets.Class)]
public class TrackBindingTypeAttribute : Attribute
{
/// <summary>
/// The type of binding for the associate track.
/// </summary>
public readonly Type type;
/// <summary>
/// Options for the the track binding
/// </summary>
public readonly TrackBindingFlags flags;
/// <summary>
/// Creates a new TrackBindingTypeAttribute.
/// </summary>
/// <param name="type"><inheritdoc cref="TrackBindingTypeAttribute.type"/></param>
public TrackBindingTypeAttribute(Type type)
{
this.type = type;
this.flags = TrackBindingFlags.All;
}
/// <summary>
/// Creates a new TrackBindingTypeAttribute.
/// </summary>
/// <param name="type"><inheritdoc cref="TrackBindingTypeAttribute.type"/></param>
/// <param name="flags"><inheritdoc cref="TrackBindingTypeAttribute.flags"/></param>
public TrackBindingTypeAttribute(Type type, TrackBindingFlags flags)
{
this.type = type;
this.flags = flags;
}
}
// indicates that child tracks are permitted on a track
// internal because not fully supported on custom classes yet
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
class SupportsChildTracksAttribute : Attribute
{
public readonly Type childType;
public readonly int levels;
public SupportsChildTracksAttribute(Type childType = null, int levels = Int32.MaxValue)
{
this.childType = childType;
this.levels = levels;
}
}
// indicates that the type should not be put on a PlayableTrack
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
class IgnoreOnPlayableTrackAttribute : System.Attribute { }
// used to flag properties as using a time field (second/frames) display
class TimeFieldAttribute : PropertyAttribute
{
public enum UseEditMode
{
None,
ApplyEditMode
}
public UseEditMode useEditMode { get; }
public TimeFieldAttribute(UseEditMode useEditMode = UseEditMode.ApplyEditMode)
{
this.useEditMode = useEditMode;
}
}
class FrameRateFieldAttribute : PropertyAttribute { }
/// <summary>
/// Use this attribute to hide a class from Timeline menus.
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class HideInMenuAttribute : Attribute { }
///<summary>
/// Use this attribute to customize the appearance of a Marker.
/// </summary>
/// Specify the style to use to draw a Marker.
/// <example>
/// <code source="../DocCodeExamples/TimelineAttributesExamples.cs" region="declare-customStyleMarkerAttr" title="CustomStyleMarkerAttr"/>
/// </example>
/// How to create a custom style rule:
/// 1) Create a 'common.uss' USS file in an Editor folder in a StyleSheets/Extensions folder hierarchy.
/// Example of valid folder paths:
/// - Assets/Editor/StyleSheets/Extensions
/// - Assets/Editor/Markers/StyleSheets/Extensions
/// - Assets/Timeline/Editor/MyMarkers/StyleSheets/Extensions
/// Rules in 'dark.uss' are used if you use the Pro Skin and rules in 'light.uss' are used otherwise.
///
/// 2)In the USS file, create a styling rule to customize the appearance of the marker.
/// <example>
/// <code>
/// MyStyle
/// {
/// /* Specify the appearance of the marker in the collapsed state here. */
/// }
///
/// MyStyle:checked
/// {
/// /* Specify the appearance of the marker in the expanded state here. */
/// }
///
/// MyStyle:focused:checked
/// {
/// /* Specify the appearance of the marker in the selected state here. */
/// }
/// </code>
/// </example>
/// <seealso cref="UnityEngine.Timeline.Marker"/>
[AttributeUsage(AttributeTargets.Class)]
public class CustomStyleAttribute : Attribute
{
/// <summary>
/// The name of the USS style.
/// </summary>
public readonly string ussStyle;
/// <summary>
/// Creates a new CustomStyleAttribute.
/// </summary>
/// <param name="ussStyle"><inheritdoc cref="CustomStyleAttribute.ussStyle"/></param>
public CustomStyleAttribute(string ussStyle)
{
this.ussStyle = ussStyle;
}
}
/// <summary>
/// Use this attribute to assign a clip, marker or track to a category in a submenu
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
internal class MenuCategoryAttribute : Attribute
{
/// <summary>
/// The menu name of the category
/// </summary>
public readonly string category;
public MenuCategoryAttribute(string category)
{
this.category = category ?? string.Empty;
}
}
}
|