Get RAPTOR

RaptorSuiteMotion

The Suite's animation timings, and the values that animate a control between states.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0

Controls read their amounts on Repaint and use them to blend between their state colours. Nothing is stored for an idle control, and the clock runs only while something is animating. A click's command runs immediately, before any animation. Hit rects are final from the first frame.

Controls are tracked by rect instead of GetControlID, because control IDs depend on position in the GUI pass and shift to other rows in a culled list. A Suite container added with AddGui, such as a pane, a floating drawer, the menu overlay, a tooltip or a flyout, owns the animations shown in it, and the clock repaints that container while they run. Unity repaints the whole window, but the other panels are served from the panel cache and the 3D view renders once per animation frame. Other windows, such as popups and module windows, request their next repaint from inside the GUI pass. Controls in camera views and Scene views do not animate.

public static class RaptorSuiteMotion

Fields

public const float MenuRise;

The distance a menu or card rises from its activator as it opens, in points.

Properties

Fade

public static float Fade { get; }

The opacity of the overlay being rendered, 1 when not fading. Theme fills, rings and icons are multiplied by it, and text is faded through GUI.color.

Reduced

public static bool Reduced { get; }

Whether Settings → Appearance → Reduce motion is on. When on, every value is at its end and nothing animates.

Methods

Alpha

public static Color Alpha(Color colour, float alpha)

Returns the colour with its alpha multiplied by alpha.

ParameterTypeDescription
colourColorThe colour.
alphafloatThe alpha multiplier.

Returns: The adjusted colour.

Amount

public static float Amount(Rect r, MotionKind kind, bool on, float seconds = Seconds.State)

Returns a single 0 to 1 amount for a control with one state, such as a reveal or a switch knob. A state change since the last pass starts the animation.

ParameterTypeDefaultDescription
rRectThe control's rect.
kindMotionKindThe kind of control.
onboolThe control's state.
secondsfloatSeconds.StateThe duration, in seconds.

Returns: The current amount.

Blend

public static Color Blend(Look look, Color rest, Color hover, Color press, Color lit)

Returns a fill blended from a control's four state colours. When nothing is animating, it returns the colour for the current state. Lit takes priority over press, and press over hover.

ParameterTypeDescription
lookLookThe control's amounts.
restColorThe fill at rest.
hoverColorThe fill on hover.
pressColorThe fill when pressed.
litColorThe fill when lit.

Returns: The blended fill.

Control

public static Look Control(Rect r, MotionKind kind, bool hovered, bool pressed = false, bool lit = false, float litSeconds = Seconds.State, float hoverIn = Seconds.HoverIn, float hoverOut = Seconds.HoverOut, float pressIn = Seconds.PressIn, float pressOut = Seconds.PressOut)

Returns a control's amounts for this Repaint. Call once per pass with the control's current state. A state change since the last pass starts the transition.

ParameterTypeDefaultDescription
rRectThe control's rect, in its drawing coordinates.
kindMotionKindThe kind of control.
hoveredboolWhether the pointer is over the control.
pressedboolfalseWhether the control is pressed.
litboolfalseWhether the control is on or current.
litSecondsfloatSeconds.StateThe lit transition duration, in seconds.
hoverInfloatSeconds.HoverInThe hover-in duration, in seconds.
hoverOutfloatSeconds.HoverOutThe hover-out duration, in seconds.
pressInfloatSeconds.PressInThe press-in duration, in seconds.
pressOutfloatSeconds.PressOutThe press-out duration, in seconds.

Returns: The amounts. They match the control's state when nothing is animating, on events other than Repaint, and when Reduce motion is on.

DrawWord

public static void DrawWord(GUIStyle style, Rect r, string words, Color ink)

Draws text in a blended colour without creating a style per colour. Use only while Look.Moving is true, and draw with the resting style otherwise.

ParameterTypeDescription
styleGUIStyleThe style.
rRectThe text rect.
wordsstringThe text.
inkColorThe text colour.

Faded

public static Color Faded(Color colour)

Returns the colour multiplied by the current fade, for direct GUI.DrawTexture calls inside a fading overlay. GUI.DrawTexture ignores GUI.color.

ParameterTypeDescription
colourColorThe colour.

Returns: The colour at the current fade.

Mix

public static Color Mix(Color a, Color b, float t)

Blends two colours. A fully transparent end takes the other end's colour, so a fill fades in without passing through black. Returns exactly a at 0 and b at 1.

ParameterTypeDescription
aColorThe colour at 0.
bColorThe colour at 1.
tfloatThe blend amount, 0 to 1.

Returns: The blended colour.

Peek

public static Look Peek(Rect r, MotionKind kind, bool hovered, bool pressed = false, bool lit = false)

Returns a control's amounts again, for a part of the control rendered later in the pass. Does not start or update any animation.

ParameterTypeDefaultDescription
rRectThe rect Control was given.
kindMotionKindThe kind Control was given.
hoveredboolWhether the pointer is over the control.
pressedboolfalseWhether the control is pressed.
litboolfalseWhether the control is on or current.

Returns: The amounts.

Play

public static void Play(IMGUIContainer host, int key, float from, float to, float seconds)

Animates a value from one number to another, for motion started from code, such as an overlay opening. Does nothing when Reduce motion is on. A later call continues from the current value.

ParameterTypeDescription
hostIMGUIContainerThe container that draws the value.
keyintA key unique within the container.
fromfloatThe start value.
tofloatThe end value.
secondsfloatThe duration, in seconds.

Play

public static void Play(int key, float from, float to, float seconds)

Animates a value from inside a draw pass, in the container being rendered.

ParameterTypeDescription
keyintA key unique within the container.
fromfloatThe start value.
tofloatThe end value.
secondsfloatThe duration, in seconds.

Slide

public static float Slide(Rect r, int index, float seconds = Seconds.SegmentSlide)

Returns the position of a segment highlight, in cells. It equals the selected index at rest and lies between two indexes while sliding.

ParameterTypeDefaultDescription
rRectThe rect of the whole group.
indexintThe selected index.
secondsfloatSeconds.SegmentSlideThe duration, in seconds.

Returns: The highlight position.

Value

public static float Value(IMGUIContainer host, int key, float rest)

Returns the current value of a played animation, or rest when it is not animating.

ParameterTypeDescription
hostIMGUIContainerThe container that draws the value.
keyintThe value's key.
restfloatThe value returned when not animating.

Returns: The current value.

Value

public static float Value(int key, float rest)

Returns the current value of a played animation in the container being rendered, or rest when it is not animating.

ParameterTypeDescription
keyintThe value's key.
restfloatThe value returned when not animating.

Returns: The current value.