/************************************************************************************************************************/ /// <summary>Draws a slider for controlling the current <see cref="AnimancerState.Time"/>.</summary> private void DoTimeSliderGUI() { if (!State.HasLength) { return; } float length; var time = GetWrappedTime(out length); if (length == 0) { return; } var area = AnimancerEditorUtilities.GetRect(true); var normalized = DoNormalizedTimeToggle(ref area); string label; float max; if (normalized) { label = "Normalized Time"; time /= length; max = 1; } else { label = "Time"; max = length; } DoLoopCounterGUI(ref area, length); EditorGUI.BeginChangeCheck(); label = AnimancerEditorUtilities.BeginTightLabel(label); time = EditorGUI.Slider(area, label, time, 0, max); AnimancerEditorUtilities.EndTightLabel(); if (EditorGUI.EndChangeCheck()) { if (normalized) { State.NormalizedTime = time; } else { State.Time = time; } State.Root.Evaluate(); } }
/************************************************************************************************************************/ /// <summary> /// Draws controls for <see cref="AnimancerState.IsPlaying"/>, <see cref="AnimancerState.Speed"/>, and /// <see cref="AnimancerState.Weight"/>. /// </summary> protected void DoPlayingDetailsGUI() { var labelWidth = EditorGUIUtility.labelWidth; var area = AnimancerEditorUtilities.GetRect(true); var right = area.xMax; // Is Playing. var label = AnimancerEditorUtilities.BeginTightLabel("Is Playing"); area.width = EditorGUIUtility.labelWidth + 16; State.IsPlaying = EditorGUI.Toggle(area, label, State.IsPlaying); AnimancerEditorUtilities.EndTightLabel(); area.x += area.width; area.xMax = right; float speedWidth, weightWidth; Rect speedRect, weightRect; AnimancerEditorUtilities.SplitHorizontally(area, "Speed", "Weight", out speedWidth, out weightWidth, out speedRect, out weightRect); var indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; // Speed. EditorGUIUtility.labelWidth = speedWidth; EditorGUI.BeginChangeCheck(); var speed = EditorGUI.FloatField(speedRect, "Speed", State.Speed); if (EditorGUI.EndChangeCheck()) { State.Speed = speed; } // Weight. EditorGUIUtility.labelWidth = weightWidth; EditorGUI.BeginChangeCheck(); var weight = EditorGUI.FloatField(weightRect, "Weight", State.Weight); if (EditorGUI.EndChangeCheck()) { State.Weight = weight; } EditorGUI.indentLevel = indentLevel; EditorGUIUtility.labelWidth = labelWidth; }