MW UNITY NAMESPACE








































public static class

MathematicsExtensions


Utility extension methods for Unity Vector and Quaternion Mathematics.



|Extension| Vector3

FNormalise (Vector3 V)

Summary:

Fast normalisation of a Vector3.

Params:

V:

        The Vector3 to normalise.

Returns:

Normalised Vector3.



|Extension| Vector2

FNormalise (Vector2 V)

Summary:

Fast normalisation of a Vector2.

Params:

V:

        The Vector2 to normalise.

Returns:

Normalised Vector2.



|Extension| float

FMagnitude (Vector3 V)

Summary:

Fast magnitude of a Vector3.

Params:

V:

        The Vector3 to get the magnitude of.

Returns:

The magnitude of V.



|Extension| float

FMagnitude (Vector2 V)

Summary:

Fast magnitude of a Vector2.

Params:

V:

        The Vector2 to get the magnitude of.

Returns:

The magnitude of V.



|Extension| float

FDistance (Vector3 V, Vector3 R)

Summary:

Fast distance between two Vector3s.

Params:

V:

        The Vector3 to measure the distance from.

R:

        The Vector3 to measure the distance to.

Returns:

The distance between V and R.



|Extension| MRotator

MakeRotator (Quaternion Q)

Summary:

Converts a Quaternion to an MRotator.

Params:

Q:

        The Quaternion to extract Pitch, Yaw and Roll.

Returns:

An MRotator rotated according to a Quaternion.



|Extension| Vector3

V3 (MVector M)

Summary:

Converts an MVector to a Vector3.

Params:

M:

        The MVector to convert.



|Extension| MVector

MV (Vector3 V)

Summary:

Converts a Vector3 to an MVector.

Params:

V:

        The Vector3 to convert.


public static class

Numerical


Utility extension methods for integers and floats.



|Extension| int

GetBits (float F)

Summary:

Gets the floating-point bits of a float as an int.

Params:

F:

        The float to get the bits of.

Returns:

The 1:1 bit conversion of F to an int.



|Extension| void

SetBits (float F, int I)

Summary:

Set the bits of a float to the bits of an int.

Params:

F:

        The float to set the bits of.

I:

        The bits to pass into F.



|Extension| bool

GetBit (float F, int BitIndex)

Summary:

Gets the bit at BitIndex of float F.

Remarks:

This gets the bits as they are in the floating-point format defined by IEEE-754.

Params:

F:

        The float to get the bit of.

BitIndex:

        The index of the bit. Range 0 to 32.

Returns:

True if the bit of F at BitIndex is 1.



|Extension| bool

GetBit (int I, int BitIndex)

Summary:

Gets the bit at BitIndex of int I.

Params:

I:

        The int to get the bit of.

BitIndex:

        The index of the bit. Range 0 to 32.

Returns:

True if the bit of I at BitIndex is 1.



|Extension| float

FlipBit (float& F, int BitIndex)

Summary:

Flips the bit at BitIndex of float F.

Remarks:

This flips the bits as they are in the floating-point format defined by IEEE-754.

Params:

F:

        The float to flip the bit of.

BitIndex:

        The index of the bit. Range 0 to 32.

Returns:

The resulting float.



|Extension| int

FlipBit (int& I, int BitIndex)

Summary:

Flips the bit at BitIndex of int I.

Params:

I:

        The int to flip the bit of.

BitIndex:

        The index of the bit. Range 0 to 32.

Returns:

The resulting int.



public static bool

IsZero (float F, float Tolerance)

Summary:

Whether or not a float is considered to be zero.

Params:

F:

        The float to check.

Tolerance:

        The threshold for F to be considered zero.

Returns:

True if F is +- Tolerance of zero.



|Extension| bool

IsIllegalFloat (float F, EIllegalFlags Flags)

Summary:

Checks if a float cannot be used for arithmetic.

Params:

F:

        The float to check.

Flags:

        The flags to check against and consider a float as inoperable.

Returns:

True if F returns a positive result against Flags.


public eunm : byte

EIllegalFlags


Flags used to check if a float cannot be used for arithmetic.


NaN


PositiveInfinity


NegativeInfinity


public static class

ObjectExtensions


Utility extension methods for C# objects.



|Extension| bool

IsT (Object O)

Summary:

Is an object derived from T?

Params:

O:

        The object to check if it derives from T.

Returns:

True if O inherits I.



|Extension| T

CastT (Object O)

Summary:

Cast an object to a Type.

Params:

O:

        The object to cast.

Returns:

O of type T if O is T, otherwise null.



public static T

UCastT (Object O)

Summary:

Cast a GameObject to T if it is attached, implemented, or derived.

Params:

O:

        The object to check if it is T is attached, implemented, or derived.

Returns:

O as T or default.



|Extension| bool

ImplementsT (Object O)

Summary:

Check if O implements interface I.

Params:

O:

        The object to convert.

Returns:

True if O implements I.



|Extension| bool

ImplementsT (Object O, T& Interface)

Summary:

Check if O implements interface I.

Remarks:

This is identical to O.Cast() != null.

Params:

O:

        The object to convert.

Interface:

        O's implementation of I.

Returns:

True if O implements I.



|Extension| int

GetLastIndex (string String)

Summary:

The index of the last character in String. If String is null or empty, then -1.

Returns:

The last index.



|Extension| char

GetLastChar (string String)

Summary:

The last character of this String. If String is null or empty, then \0.

Returns:

The last character.



|Extension| string

MakeStringStart (string String, int Start)

Summary:

Make String begin at Start. If String is null or empty, then string.Empty.

Remarks:

Assumes Start < the Length of String.

Start:

        The number of characters to skip from the beginning.

Returns:

A substring ignoring the first Start characters.



|Extension| string

MakeStringEnd (string String, int End)

Summary:

Make String terminate at End. If String is null or empty, then string.Empty.

End:

        The number of characters to skip from GetLastIndex().

Returns:

A substring ignoring the last End characters.



|Extension| void

GetPositionAndRotation (Transform T, Vector3& Position, Quaternion& Rotation)

Summary:

Gets the position and Rotation



|Extension| T

GetOrAddComponentT (GameObject G)

Summary:

Gets or Adds T Component to a GameObject.

Params:

G:

        The GameObject to Get or Add T.

Returns:

The T Component attached to G.



|Extension| T

GetOrAddComponentT (Transform R)

Summary:

Gets or Adds T Component to a Transform.

Params:

R:

        The Transform to Get or Add T.

Returns:

The T Component attached to R.



|Extension| bool

IsT (MonoBehaviour B)

Summary:

Is a MonoBehaviour derived from T?

Params:

B:

        The MonoBehaviour to check if it derives from T.

Returns:

True if B inherits T.



|Extension| bool

IsT (MonoBehaviour B, T& Behaviour)

Summary:

Is a MonoBehaviour derived from T? If so, cast it to T.

Params:

B:

        The MonoBehaviour to check if it derives from T.

Behaviour:

        Out B as T, if B derives from T.

Returns:

True if B inherits T.



|Extension| bool

IsT (GameObject G)

Summary:

Does G have an attached T component?

Params:

G:

        The GameObject to check if it has an attached T component.

Returns:

True if G has an attached T component.



|Extension| bool

IsT (GameObject G, T& Component)

Summary:

Does G have an attached T component?

Params:

G:

        The GameObject to check if it has or is T.

Component:

        Out the attached Component, otherwise null.

Returns:

True if G has an attached T component.


public static class

UnityPhysicsExtensions


Utility extension methods for Unity Rigidbody and Rigidbody 2D Physics.



|Extension| float

FMagnitude (Rigidbody R)

Summary:

Fast magnitude of a Rigidbody's velocity.

Params:

R:

        The Rigidbody to get the magnitude of.

Returns:

The magnitude of R's velocity.



|Extension| float

FMagnitude (Rigidbody2D R)

Summary:

Fast magnitude of a Rigidbody2D's velocity.

Params:

R:

        The Rigidbody2D to get the magnitude of.

Returns:

The magnitude of R's velocity.



|Extension| float

FDirection (Rigidbody R)

Summary:

Fast direction of a Rigidbody's velocity.

Params:

R:

        The Rigidbody to get the direction of.

Returns:

The direction of R's velocity.



|Extension| float

FDirection (Rigidbody2D R)

Summary:

Fast direction of a Rigidbody2D's velocity.

Params:

R:

        The Rigidbody2D to get the direction of.

Returns:

The direction of R's velocity.



|Extension| bool

Launch (Rigidbody R, MVector Target, float LaunchSpeed, bool bUseHighArc, bool bDebug)

Summary:

Launches this Rigidbody towards Target at LaunchSpeed in an arc.

Params:

R:

        The Rigidbody to launch.

Target:

        The position to hit.

LaunchSpeed:

        The speed to launch at.

bUseHighArc:

        True to use a high arc trajectory, false otherwise.

bDebug:

        True to debug the trajectory of the launch.

Returns:

True if R can be launched at LaunchSpeed to Target.



|Extension| void

Launch (Rigidbody R, MVector Target, float PeakHeight, float& Time, bool bLaunchRegardless)

Summary:

Launches this Rigidbody towards Target by reaching a Peak Height, then arcing downwards.

Params:

R:

        The Rigidbody to launch.

Target:

        The position to hit.

PeakHeight:

        The maximum altitude the Rigidbody should reach before arcing downwards towards Target.

Time:

        The time for R to reach Target.

bLaunchRegardless:

        True if R should launch and hit Target, regardless of Peak Height.



|Extension| bool

Launch (Rigidbody2D R, MVector Target, float LaunchSpeed, bool bUseHighArc, bool bDebug)

Summary:

Launches this Rigidbody towards Target at LaunchSpeed in an arc.

Params:

R:

        The Rigidbody to launch.

Target:

        The position to hit.

LaunchSpeed:

        The speed to launch at.

bUseHighArc:

        True to use a high arc trajectory, false otherwise.

bDebug:

        True to debug the trajectory of the launch.

Returns:

True if R can be launched at LaunchSpeed to Target.



|Extension| void

Launch (Rigidbody2D R, MVector Target, float PeakHeight, float& Time, bool bLaunchRegardless)

Summary:

Launches this Rigidbody towards Target by reaching a Peak Height, then arcing downwards.

Params:

R:

        The Rigidbody to launch.

Target:

        The position to hit.

PeakHeight:

        The maximum altitude the Rigidbody should reach before arcing downwards towards Target.

Time:

        The time for R to reach Target.

bLaunchRegardless:

        True if R should launch and hit Target, regardless of Peak Height.