/
CinemachinePropertyAttribute.cs
143 lines (123 loc) · 6.22 KB
/
CinemachinePropertyAttribute.cs
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
using System;
using UnityEngine;
namespace Unity.Cinemachine
{
/// <summary>
/// Property applied to legacy input axis name specification. Used for custom drawing in the inspector.
/// </summary>
public sealed class InputAxisNamePropertyAttribute : PropertyAttribute {}
/// <summary>
/// Suppresses the top-level foldout on a complex property
/// </summary>
public sealed class HideFoldoutAttribute : PropertyAttribute {}
/// <summary>Hide this property if a component of a given type is not present</summary>
public sealed class HideIfNoComponentAttribute : PropertyAttribute
{
/// <summary>The name of the field controlling the enabled state</summary>
public Type ComponentType;
/// <summary>Constructor</summary>
/// <param name="type">Type of the component to check for</param>
public HideIfNoComponentAttribute(Type type) => ComponentType = type;
}
/// <summary>
/// Draw a foldout with an Enabled toggle that shadows a field inside the foldout
/// </summary>
public class FoldoutWithEnabledButtonAttribute : PropertyAttribute
{
/// <summary>The name of the field controlling the enabled state</summary>
public string EnabledPropertyName;
/// <summary>Constructor</summary>
/// <param name="enabledProperty">The name of the field controlling the enabled state</param>
public FoldoutWithEnabledButtonAttribute(string enabledProperty = "Enabled")
=> EnabledPropertyName = enabledProperty;
}
/// <summary>
/// Draw a FoldoutWithEnabledButtonAttribute on a single line
/// </summary>
public sealed class EnabledPropertyAttribute : FoldoutWithEnabledButtonAttribute
{
/// <summary>Text to display to the right of the toggle button when disabled</summary>
public string ToggleDisabledText;
/// <summary>Constructor</summary>
/// <param name="enabledProperty">The name of the field controlling the enabled state</param>
/// <param name="toggleText">Text to display to the right of the toggle button</param>
public EnabledPropertyAttribute(string enabledProperty = "Enabled", string toggleText = "")
: base(enabledProperty) => ToggleDisabledText = toggleText;
}
/// <summary>
/// Property applied to int or float fields to generate a slider in the inspector.
/// </summary>
[Obsolete("Use RangeAttribute instead")]
public sealed class RangeSliderAttribute : PropertyAttribute
{
/// <summary>Minimum value for the range slider</summary>
public float Min;
/// <summary>Maximum value for the range slider</summary>
public float Max;
/// <summary>Constructor for the range slider attribute</summary>
/// <param name="min">Minimum value for the range slider</param>
/// <param name="max">Maximum value for the range slider</param>
public RangeSliderAttribute(float min, float max) { Min = min; Max = max; }
}
/// <summary>
/// Property applied to int or float fields to generate a minmax range slider in the inspector.
/// </summary>
public sealed class MinMaxRangeSliderAttribute : PropertyAttribute
{
/// <summary>Minimum value for the range slider</summary>
public float Min;
/// <summary>Maximum value for the range slider</summary>
public float Max;
/// <summary>Constructor for the range slider attribute</summary>
/// <param name="min">Minimum value for the range slider</param>
/// <param name="max">Maximum value for the range slider</param>
public MinMaxRangeSliderAttribute(float min, float max) { Min = min; Max = max; }
}
/// <summary>
/// Property applied to LensSetting properties.
/// Will cause the property drawer to hide the ModeOverride setting.
/// </summary>
public sealed class LensSettingsHideModeOverridePropertyAttribute : PropertyAttribute {}
/// <summary>Property to display a SensorSize field</summary>
public sealed class SensorSizePropertyAttribute : PropertyAttribute {}
/// <summary>Property field is a Tag.</summary>
public sealed class TagFieldAttribute : PropertyAttribute {}
/// <summary>
/// Used for custom drawing in the inspector. Inspector will show a foldout with the asset contents
/// </summary>
/// GML TODO: delete this attribute
public sealed class CinemachineEmbeddedAssetPropertyAttribute : PropertyAttribute
{
/// <summary>If true, inspector will display a warning if the embedded asset is null</summary>
public bool WarnIfNull;
/// <summary>Standard constructor</summary>
/// <param name="warnIfNull">If true, inspector will display a warning if the embedded asset is null</param>
public CinemachineEmbeddedAssetPropertyAttribute(bool warnIfNull = false) { WarnIfNull = warnIfNull; }
}
/// <summary>
/// Property applied to Vector2 to treat (x, y) as (min, max).
/// Used for custom drawing in the inspector.
/// </summary>
public sealed class Vector2AsRangeAttribute : PropertyAttribute {}
/// <summary>
/// Attribute used by camera pipeline authoring components to indicate
/// which stage of the pipeline they belong in.
/// </summary>
public sealed class CameraPipelineAttribute : System.Attribute
{
/// <summary>Get the stage in the Camera Pipeline in which to position this component</summary>
public CinemachineCore.Stage Stage { get; private set; }
/// <summary>Constructor: Pipeline Stage is defined here.</summary>
/// <param name="stage">The stage in the Camera Pipeline in which to position this component</param>
public CameraPipelineAttribute(CinemachineCore.Stage stage) { Stage = stage; }
}
/// <summary>
/// Attribute applied to a CinemachineVirtualCameraBase property to produce
/// a child camera selector in the inspectoe.
/// </summary>
public sealed class ChildCameraPropertyAttribute : PropertyAttribute {}
/// <summary>
/// Draws BlenderSettings asset embedded within the inspector.
/// </summary>
public sealed class EmbeddedBlenderSettingsPropertyAttribute : PropertyAttribute {}
}