RaptorSuiteMotion
The Suite's animation timings, and the values that animate a control between states.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, 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 RaptorSuiteMotionFields
MenuRise
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.
| Parameter | Type | Description |
|---|---|---|
colour | Color | The colour. |
alpha | float | The 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| r | Rect | The control's rect. | |
kind | MotionKind | The kind of control. | |
on | bool | The control's state. | |
seconds | float | Seconds.State | The 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.
| Parameter | Type | Description |
|---|---|---|
look | Look | The control's amounts. |
rest | Color | The fill at rest. |
hover | Color | The fill on hover. |
press | Color | The fill when pressed. |
lit | Color | The 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| r | Rect | The control's rect, in its drawing coordinates. | |
kind | MotionKind | The kind of control. | |
hovered | bool | Whether the pointer is over the control. | |
pressed | bool | false | Whether the control is pressed. |
lit | bool | false | Whether the control is on or current. |
litSeconds | float | Seconds.State | The lit transition duration, in seconds. |
hoverIn | float | Seconds.HoverIn | The hover-in duration, in seconds. |
hoverOut | float | Seconds.HoverOut | The hover-out duration, in seconds. |
pressIn | float | Seconds.PressIn | The press-in duration, in seconds. |
pressOut | float | Seconds.PressOut | The 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.
| Parameter | Type | Description |
|---|---|---|
style | GUIStyle | The style. |
| r | Rect | The text rect. |
words | string | The text. |
ink | Color | The 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.
| Parameter | Type | Description |
|---|---|---|
colour | Color | The 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.
| Parameter | Type | Description |
|---|---|---|
| a | Color | The colour at 0. |
| b | Color | The colour at 1. |
| t | float | The 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| r | Rect | The rect Control was given. | |
kind | MotionKind | The kind Control was given. | |
hovered | bool | Whether the pointer is over the control. | |
pressed | bool | false | Whether the control is pressed. |
lit | bool | false | Whether 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.
| Parameter | Type | Description |
|---|---|---|
host | IMGUIContainer | The container that draws the value. |
key | int | A key unique within the container. |
from | float | The start value. |
to | float | The end value. |
seconds | float | The 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.
| Parameter | Type | Description |
|---|---|---|
key | int | A key unique within the container. |
from | float | The start value. |
to | float | The end value. |
seconds | float | The 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| r | Rect | The rect of the whole group. | |
index | int | The selected index. | |
seconds | float | Seconds.SegmentSlide | The 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.
| Parameter | Type | Description |
|---|---|---|
host | IMGUIContainer | The container that draws the value. |
key | int | The value's key. |
rest | float | The 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.
| Parameter | Type | Description |
|---|---|---|
key | int | The value's key. |
rest | float | The value returned when not animating. |
Returns: The current value.
Related types
- RaptorSuiteMotion.FadeScope: Fades everything shown inside it.
- RaptorSuiteMotion.Look: A control's hover, press and lit amounts, each 0 to 1.
- RaptorSuiteMotion.OffsetScope: Offsets everything shown inside it during Repaint, leaving hit rects in place.
- RaptorSuiteMotion.Seconds: The timing table, in seconds.
- MotionKind: The kind of control a tracked motion value belongs to.