/// <summary>Draws the GUI of the state at the specified `index`.</summary> protected void DoElementGUI(Rect animationArea, Rect speedArea, Rect syncArea, int index, SerializedProperty state, SerializedProperty speed) { DoAnimationField(animationArea, state); if (speed != null) { EditorGUI.PropertyField(speedArea, speed, GUIContent.none); } else// If this element doesn't have its own speed property, just show 1. { EditorGUI.BeginProperty(speedArea, GUIContent.none, CurrentSpeeds); var value = Units.UnitsAttribute.DoSpecialFloatField( speedArea, null, 1, Units.AnimationSpeedAttribute.DisplayConverters[0]); // Middle Click toggles from 1 to -1. if (AnimancerGUI.TryUseClickEvent(speedArea, 2)) { value = -1; } if (value != 1) { CurrentSpeeds.InsertArrayElementAtIndex(0); CurrentSpeeds.GetArrayElementAtIndex(0).floatValue = 1; CurrentSpeeds.arraySize = CurrentAnimations.arraySize; CurrentSpeeds.GetArrayElementAtIndex(index).floatValue = value; } EditorGUI.EndProperty(); } DoSyncToggleGUI(syncArea, index); }
/// <summary>[Editor-Only] Ends a GUI property block started by <see cref="BeginProperty"/>.</summary> protected static void EndProperty(Rect area, SerializedProperty property, ref float value) { if (AnimancerGUI.TryUseClickEvent(area, 2)) { DefaultValueAttribute.SetToDefault(ref value, property); } if (EditorGUI.EndChangeCheck()) { property.floatValue = value; } EditorGUI.EndProperty(); }