Skip to content

runtimeutils

eisclimber edited this page Apr 4, 2026 · 1 revision

RuntimeUtils

Class in ExPresSXR.Misc

Inherits from System.Object

Summary

A helper class to use at runtime.

public static class RuntimeUtils

Enums

Name Description
RoundType How the a value can be rounded.

Methods

Name Description
ChangeSceneWithFade(ExPresSXRRig,int,bool,Action) Changes a scene whilst the current rig is faded out. Supports 'DontDestroyOnLoad' if enabled on the rig.
If no rig is provided or it does does not have a fade Rect the Scene will change instant.
DropdownToUnityFlagValue(int) Enforces Unity's Flags rules on an int from a Dropdown where 'Everything' = -1
and not only 1's.
GetRandomArrayElement(T[],bool,float[]) Return a random element from the first array given the probabilities for each object.
If a linear or weighted distribution should be used, is decided by the useWeighted value.
GetRandomArrayElement(T[],float[]) Return a random element from the first array given the probabilities for each object.
If probabilities is null, a linear distribution is used.
GetRandomArrayElementUnweighted(T[]) Returns a random element from an array using linear distribution.
GetRandomArrayElementWeighted(T[],float[]) Returns a random element from an array using weighted distribution.
GetValue01Stepped(float,int,RoundType) Steps a value on a range between [0.0f, 1.0f] to the closest of even numSteps intervals
including the borders 0.0f and 1.0f.
If numSteps is less than 1, the value will only be clamped between 0.0f and 1.0f.
GetWeightedRandomIdx(float[]) Returns a random weighted index provided by an array of probabilities that should add up to 1.0f.
IsCloseUpHandInteractor(IXRInteractor,bool) Checks if an interactor is capable of close-up interactions usually done with a hand like grabbing or poking.
Has an optional option for NearFarInteractors, checking if it is currently selecting 'near'. This does not work for hovering.
PopulateDropDownWithEnum(Dropdown,Type) Populates a UnityEngine.UI.Dropdown with the names of a given System.Enum .
PopulateTMPDropDownWithCustomValues(TMP_Dropdown,string[]) Populates a TMPro.TMP_Dropdown with the names proved by stringOptions.
PopulateTMPDropDownWithEnum(TMP_Dropdown,Type) Populates a TMPro.TMP_Dropdown with the names of a given System.Enum .
PopulateTMPDropDownWithFlags(TMP_Dropdown,Type) Populates a TMPro.TMP_Dropdown with the names of a given System.Enum .
Be careful as this will produce an entry for every combination, meaning 2^{Enum.Length} entries.
PosMod(int,int) Helper class to calculate the positive modulo for integers.
It differs from the remainder function (%) as it will return only positive values including zero.
RecursiveFindChild(Transform,string) Finds and returns the (first) UnityEngine.Transform of a child with the specified name.
RoundValue(float,RoundType) A single function to round a value to an full number in different ways.
RoundValueInt(float,RoundType) A single function to round a value to an full number as integer in different ways.
SwitchSceneAsync(int,Action) Switches the scene to the given index (if possible) and invokes a callback after completion.
TryFindExPresSXRRigReference(ExPresSXRRig) Finds the first ExPresSXRRig in the scene (if exists).
Returns true if the rig was found and set to the out parameter and false otherwise.

Be aware that the rig must be tagged as "Player"! !!This operation is expensive, call it sparingly and rather use direct References to the rig whenever possible!!| |UnityToDropdownFlagValue(T)|Changes a Unity's Flags value to an int from a Dropdown where 'Everything' is the last entry in the list.|

ExPresS XR Wiki

Tutorial Pages

Code Documentation

Clone this wiki locally