@@ -180,49 +180,25 @@ public class PlayerCubeControllerEditor : NetworkTransformEditor
180
180
private SerializedProperty m_Speed ;
181
181
private SerializedProperty m_ApplyVerticalInputToZAxis ;
182
182
183
-
184
183
public override void OnEnable ()
185
184
{
186
185
m_Speed = serializedObject .FindProperty (nameof (PlayerCubeController .Speed ));
187
186
m_ApplyVerticalInputToZAxis = serializedObject .FindProperty (nameof (PlayerCubeController .ApplyVerticalInputToZAxis ));
188
187
base .OnEnable ();
189
188
}
190
189
190
+ private void DisplayPlayerCubeControllerProperties ()
191
+ {
192
+ EditorGUILayout .PropertyField (m_Speed );
193
+ EditorGUILayout .PropertyField (m_ApplyVerticalInputToZAxis );
194
+ }
191
195
192
196
public override void OnInspectorGUI ()
193
197
{
194
198
var playerCubeController = target as PlayerCubeController ;
195
-
196
-
197
- playerCubeController .PlayerCubeControllerPropertiesVisible = EditorGUILayout .BeginFoldoutHeaderGroup (playerCubeController .PlayerCubeControllerPropertiesVisible , $" {nameof (PlayerCubeController )} Properties" );
198
- if (playerCubeController .PlayerCubeControllerPropertiesVisible )
199
- {
200
- EditorGUILayout .PropertyField (m_Speed );
201
- EditorGUILayout .PropertyField (m_ApplyVerticalInputToZAxis );
202
- }
203
- EditorGUILayout .EndFoldoutHeaderGroup ();
204
-
205
-
206
- EditorGUILayout .Space ();
207
-
208
-
209
- playerCubeController .NetworkTransformPropertiesVisible = EditorGUILayout .BeginFoldoutHeaderGroup (playerCubeController .NetworkTransformPropertiesVisible , $" {nameof (NetworkTransform )} Properties" );
210
- if (playerCubeController .NetworkTransformPropertiesVisible )
211
- {
212
- // End the header group prior to invoking the base OnInspectorGUID in order to avoid nested
213
- // foldout groups.
214
- EditorGUILayout .EndFoldoutHeaderGroup ();
215
- // If NetworkTransform properties are visible, then both the properties any modified properties
216
- // will be applied.
217
- base .OnInspectorGUI ();
218
- }
219
- else
220
- {
221
- // End the header group
222
- EditorGUILayout .EndFoldoutHeaderGroup ();
223
- // If NetworkTransform properties are not visible, then make sure we apply any modified properties.
224
- serializedObject .ApplyModifiedProperties ();
225
- }
199
+ void SetExpanded (bool expanded ) { playerCubeController .PlayerCubeControllerPropertiesVisible = expanded ; };
200
+ DrawFoldOutGroup <PlayerCubeController >(playerCubeController .GetType (), DisplayPlayerCubeControllerProperties , playerCubeController .PlayerCubeControllerPropertiesVisible , SetExpanded );
201
+ base .OnInspectorGUI ();
226
202
}
227
203
}
228
204
#endif
@@ -235,17 +211,11 @@ public class PlayerCubeController : NetworkTransform
235
211
// within the inspector view will be saved and restored the next time the
236
212
// asset/prefab is viewed.
237
213
public bool PlayerCubeControllerPropertiesVisible ;
238
- public bool NetworkTransformPropertiesVisible ;
239
214
#endif
240
-
241
-
242
215
public float Speed = 10 ;
243
216
public bool ApplyVerticalInputToZAxis ;
244
-
245
-
246
217
private Vector3 m_Motion ;
247
218
248
-
249
219
private void Update ()
250
220
{
251
221
// If not spawned or we don't have authority, then don't update
@@ -254,12 +224,10 @@ public class PlayerCubeController : NetworkTransform
254
224
return ;
255
225
}
256
226
257
-
258
227
// Handle acquiring and applying player input
259
228
m_Motion = Vector3 .zero ;
260
229
m_Motion .x = Input .GetAxis (" Horizontal" );
261
230
262
-
263
231
// Determine whether the vertical input is applied to the Y or Z axis
264
232
if (! ApplyVerticalInputToZAxis )
265
233
{
@@ -270,7 +238,6 @@ public class PlayerCubeController : NetworkTransform
270
238
m_Motion .z = Input .GetAxis (" Vertical" );
271
239
}
272
240
273
-
274
241
// If there is any player input magnitude, then apply that amount of
275
242
// motion to the transform
276
243
if (m_Motion .magnitude > 0 )
0 commit comments