/// <summary>Draws the GUI of the state at the specified `index`.</summary> protected void DoElementGUI(Rect animationArea, Rect speedArea, Rect syncArea, int index, SerializedProperty clip, SerializedProperty speed) { EditorGUI.PropertyField(animationArea, clip, GUIContent.none); if (speed != null) { EditorGUI.PropertyField(speedArea, speed, GUIContent.none); } else { EditorGUI.BeginProperty(speedArea, GUIContent.none, CurrentSpeeds); var value = EditorGUI.FloatField(speedArea, 1); if (value != 1) { CurrentSpeeds.InsertArrayElementAtIndex(0); CurrentSpeeds.GetArrayElementAtIndex(0).floatValue = 1; CurrentSpeeds.arraySize = CurrentClips.arraySize; CurrentSpeeds.GetArrayElementAtIndex(index).floatValue = value; } EditorGUI.EndProperty(); } DoSyncToggleGUI(syncArea, index); }
/// <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> /// Called when adding a new state to the list to ensure that any other relevant arrays have new /// elements added as well. /// </summary> protected virtual void OnAddElement(ReorderableList list) { var index = CurrentClips.arraySize; CurrentClips.InsertArrayElementAtIndex(index); if (CurrentSpeeds.arraySize > 0) { CurrentSpeeds.InsertArrayElementAtIndex(index); } }
/// <summary> /// Called when adding a new state to the list to ensure that any other relevant arrays have new /// elements added as well. /// </summary> protected virtual void OnAddElement(int index) { CurrentAnimations.InsertArrayElementAtIndex(index); if (CurrentSpeeds.arraySize > 0) { CurrentSpeeds.InsertArrayElementAtIndex(index); } if (CurrentSynchronizeChildren.arraySize > index) { CurrentSynchronizeChildren.InsertArrayElementAtIndex(index); } }