UI

This class is a collection of user interface and interaction methods! StereoKit uses an Immediate Mode gui system, which can be very easy to work with and modify during runtime.

You must call the UI method every frame you wish it to be available, and if you no longer want it to be present, you simply stop calling it! The id of the element is used to track its state from frame to frame, so for elements with state, you’ll want to avoid changing the id during runtime! Ids are also scoped per-window, so different windows can re-use the same id, but a window cannot use the same id twice.

Static Fields and Properties

   
Vec2 AreaRemaining How much space is available on the current layout! This is based on the current layout position, so X will give you the amount remaining on the current line, and Y will give you distance to the bottom of the layout, including the current line. These values will be 0 if you’re using 0 for the layout size on that axis.
Color ColorScheme StereoKit will generate a color palette from this color, and use it to skin the UI!
float LineHeight This is the height of a single line of text with padding in the UI’s layout system!
UISettings Settings UI sizing and layout settings. Set only for now
bool ShowVolumes Shows or hides the collision volumes of the UI! This is for debug purposes, and can help identify visible and invisible collision issues.

Static Methods

   
Button A pressable button! A button will expand to fit the text provided to it, vertically and horizontally. Text is re-used as the id. Will return true only on the first frame it is pressed!
ButtonRound A pressable button! A button will expand to fit the text provided to it, vertically and horizontally. Text is re-used as the id. Will return true only on the first frame it is pressed!
Handle This begins and ends a handle so you can just use its grabbable/moveable functionality! Behaves much like a window, except with a more flexible handle, and no header. You can draw the handle, but it will have no text on it. Returns true for every frame the user is grabbing the handle.
HandleBegin This begins a new UI group with its own layout! Much like a window, except with a more flexible handle, and no header. You can draw the handle, but it will have no text on it. Returns true for every frame the user is grabbing the handle.
HandleEnd Finishes a handle! Must be called after UI.HandleBegin() and all elements have been drawn.
HSlider A horizontal slider element! You can stick your finger in it, and slide the value up and down.
Image Adds an image to the UI!
IsInteracting Tells if the user is currently interacting with a UI element! This will be true if the hand has an active or focused UI element.
Label Adds some text to the layout! Text uses the UI’s current font settings (which are currently not exposed). Can contain newlines! May have trouble with non-latin characters. Will advance layout to next line.
LayoutArea Manually define what area is used for the UI layout. This is in the current Hierarchy’s coordinate space on the X/Y plane.
NextLine This will advance the layout to the next line. If there’s nothing on the current line, it’ll advance to the start of the next on. But this won’t have any affect on an empty line, try UI.Space for that.
PopId Removes the last root id from the stack, and moves up to the one before it!
PushId Adds a root id to the stack for the following UI elements! This id is combined when hashing any following ids, to prevent id collisions in separate groups.
Radio A Radio is similar to a button, except you can specify if it looks pressed or not regardless of interaction. This can be useful for radio-like behavior! Check an enum for a value, and use that as the ‘active’ state, Then switch to that enum value if Radio returns true.
ReserveBox Reserves a box of space for an item in the current UI layout! This doesn’t advance to the next line after it, use UI.NextLine for that.
SameLine Moves the current layout position back to the end of the line that just finished, so it can continue on the same line as the last element!
Space Adds some space! If we’re at the start of a new line, space is added vertically, otherwise, space is added horizontally.
Toggle A toggleable button! A button will expand to fit the text provided to it, vertically and horizontally. Text is re-used as the id. Will return true any time the toggle value changes!
VolumeAt An invisible volume that will trigger when a finger enters it!
WindowBegin Begins a new window! This will push a pose onto the transform stack, and all UI elements will be relative to that new pose. The pose is actually the top-center of the window. Must be finished with a call to UI.WindowEnd().
WindowEnd Finishes a window! Must be called after UI.WindowBegin() and all elements have been drawn.