Lemmings
Remappable Gestures For Unity
Loading...
Searching...
No Matches
Lemmings.LemmingFloater Struct Reference

Represents a normalized floating-point value and provides tools to remap it across data types. More...

Inherits Lemmings.ILemmingConverter.

Public Member Functions

 LemmingFloater (float raw, float min, float max)
 Creates a new LemmingFloater with the given raw value, range, and threshold.
int ToIntRange (int minimum, int maximum)
 Remaps the normalized value to an integer range.
float ToFloatRange (float minimum, float maximum)
 Remaps the normalized value to a floating-point range.
int ToIndex (int arrayCount)
 Maps the normalized value to an index in an array of a given size.
float ToCurve (AnimationCurve curve)
 Evaluates the normalized value on a Unity AnimationCurve.
Vector3 ToVector (Vector3 vectorA, Vector3 vectorB)
 Interpolates between two vectors using the normalized value.
string ToLabel (string[] labels)
 Returns a label from a list based on the normalized value.
ToEnum< T > ()
 Maps the normalized value to a value in a given enum type.
Quaternion ToQuaternion (Quaternion a, Quaternion b)
 Interpolates between two rotations using the normalized value.
Quaternion ToRotationAroundAxis (Vector3 axis, float minAngle, float maxAngle)
 Creates a rotation around a given axis by remapping the normalized value to an angle.
Quaternion ToLookRotation (Vector3 from, Vector3 to)
 Generates a look rotation from a direction interpolated between two vectors.
EvaluateNormalized< T > (Func< float, T > function)
 Evaluates a custom function against the normalized value and returns the result.
float Invert ()
 Returns the inverse of the Normalized value.
override string ToString ()
 Returns a string representation of the floater for debugging.
void SetRaw (float newRaw)
 Sets or updates the raw value.
void SetRange (float newMin, float newMax)
 Sets the min and max values of the range.
void Reset (float newRaw, float newMin, float newMax)
 Resets all internal values at once.

Data Fields

float raw
 The raw input value to normalize. Meant to update regularly.
float min
 The minimum value of the input range. Can be remotely set.
float max
 The maximum value of the input range. Can be remotely set.

Properties

object Raw [get]
float Normalized [get]
 Returns the normalized value of raw within the range [min, max], clamped between 0 and 1.
bool Over [get]
 Returns true if raw is greater than or equal to threshold.
bool InRange [get]
 Returns true if the raw value is within the specified range.
bool Under [get]
 Returns true if raw is less than or equal to threshold.
float AsAxis [get]
 This provides the normalized value in a range of -1 to 1, useful for input mapping and relative values.

Detailed Description

Represents a normalized floating-point value and provides tools to remap it across data types.

Constructor & Destructor Documentation

◆ LemmingFloater()

Lemmings.LemmingFloater.LemmingFloater ( float raw,
float min,
float max )
inline

Creates a new LemmingFloater with the given raw value, range, and threshold.

Parameters
rawThe raw input value.
minThe minimum input value.
maxThe maximum input value.
thresholdThe threshold to compare against.
Exceptions
ArgumentExceptionThrown if min and max are equal.

Member Function Documentation

◆ EvaluateNormalized< T >()

T Lemmings.LemmingFloater.EvaluateNormalized< T > ( Func< float, T > function)
inline

Evaluates a custom function against the normalized value and returns the result.

Template Parameters
TThe return type of the function.
Parameters
functionA function that takes a float (normalized) and returns a value.
Returns
The result of the function.

◆ Invert()

float Lemmings.LemmingFloater.Invert ( )
inline

Returns the inverse of the Normalized value.

Returns
A float from 1 to 0.

◆ Reset()

void Lemmings.LemmingFloater.Reset ( float newRaw,
float newMin,
float newMax )
inline

Resets all internal values at once.

Parameters
newRawNew raw value.
newMinNew minimum value.
newMaxNew maximum value.
newThresholdNew threshold value.
Exceptions
ArgumentExceptionThrown if newMin equals newMax.

◆ SetRange()

void Lemmings.LemmingFloater.SetRange ( float newMin,
float newMax )
inline

Sets the min and max values of the range.

Parameters
newMinNew minimum.
newMaxNew maximum.
Exceptions
ArgumentExceptionThrown if newMin equals newMax.

◆ SetRaw()

void Lemmings.LemmingFloater.SetRaw ( float newRaw)
inline

Sets or updates the raw value.

Parameters
newRawNew raw input.

◆ ToCurve()

float Lemmings.LemmingFloater.ToCurve ( AnimationCurve curve)
inline

Evaluates the normalized value on a Unity AnimationCurve.

Parameters
curveThe curve to evaluate.
Returns
The float value of the curve at the normalized position.

Implements Lemmings.ILemmingConverter.

◆ ToEnum< T >()

T Lemmings.LemmingFloater.ToEnum< T > ( )
inline

Maps the normalized value to a value in a given enum type.

Template Parameters
TEnum type to map into.
Returns
The enum value corresponding to the normalized index.
Type Constraints
T :Enum 

◆ ToFloatRange()

float Lemmings.LemmingFloater.ToFloatRange ( float minimum,
float maximum )
inline

Remaps the normalized value to a floating-point range.

Parameters
minimumMinimum float output value.
maximumMaximum float output value.
Returns
Float within [maximum , maximum ].

◆ ToIndex()

int Lemmings.LemmingFloater.ToIndex ( int arrayCount)
inline

Maps the normalized value to an index in an array of a given size.

Parameters
arrayCountThe size of the array.
Returns
Index from 0 to arrayCount - 1.

◆ ToIntRange()

int Lemmings.LemmingFloater.ToIntRange ( int minimum,
int maximum )
inline

Remaps the normalized value to an integer range.

Parameters
minimumMinimum integer output value.
maximumMaximum integer output value.
Returns
Integer within [minimum , maximum ].

◆ ToLabel()

string Lemmings.LemmingFloater.ToLabel ( string[] labels)
inline

Returns a label from a list based on the normalized value.

Parameters
labelsArray of labels.
Returns
A string label corresponding to the current normalized value.

◆ ToLookRotation()

Quaternion Lemmings.LemmingFloater.ToLookRotation ( Vector3 from,
Vector3 to )
inline

Generates a look rotation from a direction interpolated between two vectors.

Parameters
fromStart direction.
toEnd direction.
Returns
A look rotation Quaternion.

◆ ToQuaternion()

Quaternion Lemmings.LemmingFloater.ToQuaternion ( Quaternion a,
Quaternion b )
inline

Interpolates between two rotations using the normalized value.

Parameters
aStart rotation.
bEnd rotation.
Returns
Interpolated Quaternion.

◆ ToRotationAroundAxis()

Quaternion Lemmings.LemmingFloater.ToRotationAroundAxis ( Vector3 axis,
float minAngle,
float maxAngle )
inline

Creates a rotation around a given axis by remapping the normalized value to an angle.

Parameters
axisAxis to rotate around (must be normalized).
minAngleMinimum angle in degrees.
maxAngleMaximum angle in degrees.
Returns
A Quaternion representing the rotation.

◆ ToVector()

Vector3 Lemmings.LemmingFloater.ToVector ( Vector3 vectorA,
Vector3 vectorB )
inline

Interpolates between two vectors using the normalized value.

Parameters
vectorAStart vector.
vectorBEnd vector.
Returns
Interpolated Vector3.

Property Documentation

◆ AsAxis

float Lemmings.LemmingFloater.AsAxis
get

This provides the normalized value in a range of -1 to 1, useful for input mapping and relative values.

Implements Lemmings.ILemmingConverter.

◆ InRange

bool Lemmings.LemmingFloater.InRange
get

Returns true if the raw value is within the specified range.

Implements Lemmings.ILemmingConverter.

◆ Normalized

float Lemmings.LemmingFloater.Normalized
get

Returns the normalized value of raw within the range [min, max], clamped between 0 and 1.

Implements Lemmings.ILemmingConverter.

◆ Over

bool Lemmings.LemmingFloater.Over
get

Returns true if raw is greater than or equal to threshold.

Implements Lemmings.ILemmingConverter.

◆ Raw

object Lemmings.LemmingFloater.Raw
get

◆ Under

bool Lemmings.LemmingFloater.Under
get

Returns true if raw is less than or equal to threshold.

Implements Lemmings.ILemmingConverter.


The documentation for this struct was generated from the following file:
  • Assets/Lemmings/Scripts/Namespace/LemmingConverterStructs.cs