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