private void updateAxesForRemovedCurve(AxisTypes yAxisType) { if (!Curves.Any()) { _axes[AxisTypes.X].Reset(); } if (Curves.All(c => c.yAxisType != yAxisType)) { _axes[yAxisType].Reset(); } }
public void OnGUI() { if (Event.current.commandName == "UndoRedoPerformed") { return; } if (Curves == null || Curves.Count == 0) { GUILayout.Box("", TimelineBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MaxHeight(MaxHeight)); if (Event.current.type == EventType.Repaint) { DisplayArea = GUILayoutUtility.GetLastRect(); } GUI.Label(DisplayArea, "Press the Animate button to start animating properties!"); return; } if (Curves.Any(curve => curve == null)) { throw new NullReferenceException("One of the curves is null, this shouldn't happen"); } if (EditorWindow == null) { throw new NullReferenceException("Editor Window must be assigned a value"); } if (RebuildCurvesOnNextGUI) { CalculateBounds(); RebuildCachedCurveInformation(); // Sometimes, depending on the update order vs the serialization order, this can be null during Undo / Redo :/ if (EditorWindow != null) { EditorWindow.Repaint(); } } RebuildCurvesOnNextGUI = false; foreach (var cachedRenderingData in cachedKeyframePositions) { if (SelectedObjects.Contains(cachedRenderingData.Key)) { cachedRenderingData.Value.IsKeyframeSelected = true; } else { cachedRenderingData.Value.IsKeyframeSelected = false; } } if (cachedKeyframePositions == null || (cachedKeyframePositions.Count == 0 && Curves.Count > 0)) { RebuildCachedCurveInformation(); } GUILayout.Box("", TimelineBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MaxHeight(MaxHeight)); if (Event.current.type == EventType.Repaint) { var displayAreaRect = GUILayoutUtility.GetLastRect(); var previousDisplayArea = DisplayArea; DisplayArea = displayAreaRect; if (DisplayArea != previousDisplayArea) { RebuildCachedCurveInformation(); } } using (new GUIBeginArea(DisplayArea)) { if (Event.current.type == EventType.Repaint) { DrawGrid(); } for (var n = 0; n < Curves.Count; n++) { DrawCurve(Curves[n], AnimationCurveEditorUtility.GetCurveColor(n)); } HandleEvent(); } }