forked from MixedRealityToolkit/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraSimulationSettingsDrawer.cs
More file actions
204 lines (183 loc) · 8.74 KB
/
Copy pathCameraSimulationSettingsDrawer.cs
File metadata and controls
204 lines (183 loc) · 8.74 KB
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
// Copyright (c) Mixed Reality Toolkit Contributors
// Licensed under the BSD 3-Clause
using MixedReality.Toolkit.Editor;
using UnityEditor;
using UnityEngine;
namespace MixedReality.Toolkit.Input.Simulation.Editor
{
/// <summary>
/// A custom property drawer for <see cref="CameraSimulationSettings"/> fields.
/// </summary>
[CustomPropertyDrawer(typeof(CameraSimulationSettings))]
public class CameraSimulationSettingsDrawer : PropertyDrawer
{
private readonly GUIContent simEnabledContent = new GUIContent("Simulation enabled");
private readonly GUIContent originOffsetContent = new GUIContent("Offset");
private readonly GUIContent moveSpeedContent = new GUIContent("Speed");
private readonly GUIContent moveSmoothingContent = new GUIContent("Smoothed");
private readonly GUIContent frameRateIndependentContent = new GUIContent("Frame Rate Independent");
private readonly GUIContent moveDepthContent = new GUIContent("Depth");
private readonly GUIContent moveHorizontalContent = new GUIContent("Horizontal");
private readonly GUIContent moveVerticalContent = new GUIContent("Vertical");
private readonly GUIContent rotationSensitivityContent = new GUIContent("Sensitivity");
private readonly GUIContent pitchContent = new GUIContent("Pitch");
private readonly GUIContent invertPitchContent = new GUIContent("Invert pitch");
private readonly GUIContent yawContent = new GUIContent("Yaw");
private readonly GUIContent rollContent = new GUIContent("Roll");
/// <inheritdoc />
public override float GetPropertyHeight(
SerializedProperty property,
GUIContent label)
{
return PropertyDrawerUtilities.CalculatePropertyHeight(15);
}
/// <inheritdoc />
public override void OnGUI(
Rect position,
SerializedProperty property,
GUIContent label)
{
bool lastMode = EditorGUIUtility.wideMode;
EditorGUIUtility.wideMode = true;
EditorGUI.BeginProperty(position, label, property);
EditorGUI.PrefixLabel(
position,
GUIUtility.GetControlID(FocusType.Passive),
label,
EditorStyles.boldLabel);
EditorGUI.indentLevel++;
int rowMultiplier = 0;
SerializedProperty simEnabled = property.FindPropertyRelative("simulationEnabled");
SerializedProperty originOffset = property.FindPropertyRelative("originOffset");
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
simEnabled, simEnabledContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
originOffset, originOffsetContent);
#region Move controls
SerializedProperty moveSpeed = property.FindPropertyRelative("moveSpeed");
SerializedProperty moveSmoothing = property.FindPropertyRelative("isMovementSmoothed");
SerializedProperty frameRateIndependent = property.FindPropertyRelative("isFrameRateIndependent");
SerializedProperty moveDepth = property.FindPropertyRelative("moveDepth");
SerializedProperty moveHorizontal = property.FindPropertyRelative("moveHorizontal");
SerializedProperty moveVertical = property.FindPropertyRelative("moveVertical");
EditorGUI.LabelField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
"Movement", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
moveSpeed, moveSpeedContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
frameRateIndependent, frameRateIndependentContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
moveSmoothing, moveSmoothingContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
moveDepth, moveDepthContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
moveHorizontal, moveHorizontalContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
moveVertical, moveVerticalContent);
EditorGUI.indentLevel--;
#endregion Move controls
#region Rotate controls
SerializedProperty rotationSensitivity = property.FindPropertyRelative("rotationSensitivity");
SerializedProperty pitch = property.FindPropertyRelative("pitch");
SerializedProperty invertPitch = property.FindPropertyRelative("invertPitch");
SerializedProperty yaw = property.FindPropertyRelative("yaw");
SerializedProperty roll = property.FindPropertyRelative("roll");
EditorGUI.LabelField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
"Rotation", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
rotationSensitivity, rotationSensitivityContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
pitch, pitchContent);
EditorGUI.indentLevel++;
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
invertPitch, invertPitchContent);
EditorGUI.indentLevel--;
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
yaw, yawContent);
EditorGUI.PropertyField(
PropertyDrawerUtilities.GetPosition(
position,
PropertyDrawerUtilities.VerticalSpacing,
++rowMultiplier,
PropertyDrawerUtilities.Height),
roll, rollContent);
EditorGUI.indentLevel--;
#endregion Rotate controls
EditorGUI.indentLevel--;
EditorGUIUtility.wideMode = lastMode;
EditorGUI.EndProperty();
}
}
}