// True if the keyframe is shown in the inspector window. public static bool IsKeyframeActiveInInspector(BaseKeyframe keyFrame) { if (KeyframeInspectorWindow.inspectorEnabled && KeyframeInspectorWindow.GetActiveKeyframeId() == keyFrame.id) { return(true); } else { return(false); } }
// Sticks to bottom of rect, and can slide horizontally only. public static void DrawHorizontalKeyMarker( Rect fullSliderRect, BaseKeyframe keyFrame, UnityEngine.Object undoObject, out bool didSingleClick, out bool isDragging, out bool keyFrameTimeChanged) { Rect markerRect = new Rect( SkyEditorUtility.GetXPositionForPercent(fullSliderRect, keyFrame.time) - (KEY_GRIP_WIDTH / 2), fullSliderRect.y + fullSliderRect.height - (KEY_GRIP_HEIGHT) / 2.0f, KEY_GRIP_WIDTH, KEY_GRIP_HEIGHT); bool wasDragging = TimelineSelection.selectedControlUUID != null && TimelineSelection.selectedControlUUID == keyFrame.id; bool isMouseOverControl = markerRect.Contains(Event.current.mousePosition); didSingleClick = false; isDragging = wasDragging; keyFrameTimeChanged = false; // Single Click. if (Event.current.isMouse) { // Check for single click, with no drag. if (Event.current.type == EventType.MouseUp && TimelineSelection.selectedControlUUID == null && isMouseOverControl) { Event.current.Use(); didSingleClick = true; } // Start slide. if (TimelineSelection.selectedControlUUID == null && isMouseOverControl && Event.current.type == EventType.MouseDrag) { TimelineSelection.selectedControlUUID = keyFrame.id; Event.current.Use(); isDragging = true; } // End Slide. if (wasDragging && Event.current.type == EventType.MouseUp) { TimelineSelection.selectedControlUUID = null; Event.current.Use(); isDragging = false; } // If we're dragging this keyframe grip, move it's position. if (isDragging || wasDragging) { // Update key frame time value and reposition rectangle. Undo.RecordObject(undoObject, "Keyframe time position changed."); keyFrame.time = SkyEditorUtility.GetPercentForXPosition(fullSliderRect, Event.current.mousePosition.x); keyFrameTimeChanged = true; isDragging = true; // Position the marker rect. markerRect.x = SkyEditorUtility.GetXPositionForPercent(fullSliderRect, keyFrame.time) - (KEY_GRIP_WIDTH / 2); Event.current.Use(); } } bool showAsActive = IsKeyframeActiveInInspector(keyFrame) || isDragging; // Draw the marker at this location. SkyEditorUtility.DrawKeyMarker(markerRect, showAsActive); }
public int CompareTo(object other) { BaseKeyframe otherFrame = other as BaseKeyframe; return(time.CompareTo(otherFrame.time)); }
public static float ProgressBetweenSurroundingKeyframes(float time, BaseKeyframe beforeKey, BaseKeyframe afterKey) { return(ProgressBetweenSurroundingKeyframes(time, beforeKey.time, afterKey.time)); }