private static void GUICurveField(Rect position, SerializedProperty maxCurve, SerializedProperty minCurve, Color color, Rect ranges, ModuleUI.CurveFieldMouseDownCallback mouseDownCallback) { int controlID = GUIUtility.GetControlID(1321321231, EditorGUIUtility.native, position); Event current = Event.current; EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl != EventType.MouseDown) { if (typeForControl != EventType.Repaint) { if (typeForControl == EventType.ValidateCommand) { if (current.commandName == "UndoRedoPerformed") { AnimationCurvePreviewCache.ClearCache(); } } } else { Rect position2 = position; if (minCurve == null) { EditorGUIUtility.DrawCurveSwatch(position2, null, maxCurve, color, EditorGUI.kCurveBGColor, ranges); } else { EditorGUIUtility.DrawRegionSwatch(position2, maxCurve, minCurve, color, EditorGUI.kCurveBGColor, ranges); } EditorStyles.colorPickerBox.Draw(position2, GUIContent.none, controlID, false); } } else if (position.Contains(current.mousePosition) && mouseDownCallback != null && mouseDownCallback(current.button, position, ranges)) { current.Use(); } }
private static void GUICurveField(Rect position, SerializedProperty maxCurve, SerializedProperty minCurve, Color color, Rect ranges, ModuleUI.CurveFieldMouseDownCallback mouseDownCallback) { int controlId = GUIUtility.GetControlID(1321321231, EditorGUIUtility.native, position); Event current = Event.current; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (!position.Contains(current.mousePosition) || mouseDownCallback == null || !mouseDownCallback(current.button, position, ranges)) { break; } current.Use(); break; case EventType.Repaint: Rect position1 = position; if (minCurve == null) { EditorGUIUtility.DrawCurveSwatch(position1, (AnimationCurve)null, maxCurve, color, EditorGUI.kCurveBGColor, ranges); } else { EditorGUIUtility.DrawRegionSwatch(position1, maxCurve, minCurve, color, EditorGUI.kCurveBGColor, ranges); } EditorStyles.colorPickerBox.Draw(position1, GUIContent.none, controlId, false); break; case EventType.ValidateCommand: if (!(current.commandName == "UndoRedoPerformed")) { break; } AnimationCurvePreviewCache.ClearCache(); break; } }