C# Class NGUIMath, TheUnseen

Helper class containing generic functions used throughout the UI library.
Afficher le fichier Open project: henryj41043/TheUnseen Class Usage Examples

Méthodes publiques

Méthode Description
AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top ) : void

Adjust the widget's rectangle based on the specified modifier values.

AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top, int minWidth, int minHeight ) : void

Adjust the widget's rectangle based on the specified modifier values.

AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top, int minWidth, int minHeight, int maxWidth, int maxHeight ) : void

Adjust the widget's rectangle based on the specified modifier values.

CalculateAbsoluteWidgetBounds ( Transform trans ) : Bounds

Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).

CalculateRelativeWidgetBounds ( Transform trans ) : Bounds

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).

CalculateRelativeWidgetBounds ( Transform root, Transform child ) : Bounds

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).

CalculateRelativeWidgetBounds ( Transform root, Transform child, bool considerInactive ) : Bounds

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).

CalculateRelativeWidgetBounds ( Transform trans, bool considerInactive ) : Bounds

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).

ConstrainRect ( Vector2 minRect, Vector2 maxRect, Vector2 minArea, Vector2 maxArea ) : Vector2

Constrain 'rect' to be within 'area' as much as possible, returning the Vector2 offset necessary for this to happen. This function is useful when trying to restrict one area (window) to always be within another (viewport).

ConvertToPixels ( Rect rect, int width, int height, bool round ) : Rect

Convert from bottom-left based UV coordinates to top-left based pixel coordinates.

ConvertToTexCoords ( Rect rect, int width, int height ) : Rect

Convert from top-left based pixel coordinates to bottom-left based UV coordinates.

DistanceToRectangle ( Vector2 screenPoints, Vector2 mousePos ) : float

Determine the distance from the mouse position to the screen space rectangle specified by the 4 points.

DistanceToRectangle ( Vector3 worldPoints, Vector2 mousePos, Camera cam ) : float

Determine the distance from the mouse position to the world rectangle specified by the 4 points.

GetPivot ( Vector2 offset ) : UIWidget.Pivot

Helper function that converts the pivot offset to a pivot point.

GetPivotOffset ( UIWidget, pv ) : Vector2

Helper function that converts the widget's pivot enum into a 0-1 range vector.

MakePixelPerfect ( Rect rect ) : Rect

Round the pixel rectangle's dimensions.

MakePixelPerfect ( Rect rect, int width, int height ) : Rect

Round the texture coordinate rectangle's dimensions.

MoveRect ( UIRect, rect, float x, float y ) : void

Adjust the rectangle's position using the specified local delta coordinates.

MoveWidget ( UIRect, w, float x, float y ) : void

Adjust the widget's position using the specified local delta coordinates.

ResizeWidget ( UIWidget, w, UIWidget, pivot, float x, float y, int minWidth, int minHeight ) : void

Given the specified dragged pivot point, adjust the widget's dimensions.

ResizeWidget ( UIWidget, w, UIWidget, pivot, float x, float y, int minWidth, int minHeight, int maxWidth, int maxHeight ) : void

Given the specified dragged pivot point, adjust the widget's dimensions.

RotateTowards ( float from, float to, float maxAngle ) : float

Since there is no Mathf.RotateTowards...

SpringDampen ( Vector2 &velocity, float strength, float deltaTime ) : Vector2

Same as the Vector3 version, it's a framerate-independent Lerp.

SpringDampen ( Vector3 &velocity, float strength, float deltaTime ) : Vector3

This code is not framerate-independent: target.position += velocity; velocity = Vector3.Lerp(velocity, Vector3.zero, Time.deltaTime * 9f); But this code is: target.position += NGUIMath.SpringDampen(ref velocity, 9f, Time.deltaTime);

SpringLerp ( Quaternion from, Quaternion to, float strength, float deltaTime ) : Quaternion

Quaternion.Slerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.

SpringLerp ( Vector2 from, Vector2 to, float strength, float deltaTime ) : Vector2

Vector2.Lerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.

SpringLerp ( Vector3 from, Vector3 to, float strength, float deltaTime ) : Vector3

Vector3.Lerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.

SpringLerp ( float strength, float deltaTime ) : float

Calculate how much to interpolate by.

SpringLerp ( float from, float to, float strength, float deltaTime ) : float

Mathf.Lerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.

Private Methods

Méthode Description
ClampIndex ( int val, int max ) : int
ColorToInt ( Color c ) : int
DecimalToHex ( int num ) : string
DecimalToHexChar ( int num ) : char
DistancePointToLineSegment ( Vector2 point, Vector2 a, Vector2 b ) : float

Determine the distance from the specified point to the line segment.

HexToColor ( uint val ) : Color
HexToDecimal ( char ch ) : int
IntToBinary ( int val, int bits ) : string
IntToColor ( int val ) : Color
Lerp ( float from, float to, float factor ) : float
RepeatIndex ( int val, int max ) : int
Wrap01 ( float val ) : float
WrapAngle ( float angle ) : float

Method Details

AdjustWidget() static public méthode

Adjust the widget's rectangle based on the specified modifier values.
static public AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top ) : void
w UIWidget,
left float
bottom float
right float
top float
Résultat void

AdjustWidget() static public méthode

Adjust the widget's rectangle based on the specified modifier values.
static public AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top, int minWidth, int minHeight ) : void
w UIWidget,
left float
bottom float
right float
top float
minWidth int
minHeight int
Résultat void

AdjustWidget() static public méthode

Adjust the widget's rectangle based on the specified modifier values.
static public AdjustWidget ( UIWidget, w, float left, float bottom, float right, float top, int minWidth, int minHeight, int maxWidth, int maxHeight ) : void
w UIWidget,
left float
bottom float
right float
top float
minWidth int
minHeight int
maxWidth int
maxHeight int
Résultat void

CalculateAbsoluteWidgetBounds() static public méthode

Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).
static public CalculateAbsoluteWidgetBounds ( Transform trans ) : Bounds
trans Transform
Résultat Bounds

CalculateRelativeWidgetBounds() static public méthode

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).
static public CalculateRelativeWidgetBounds ( Transform trans ) : Bounds
trans Transform
Résultat Bounds

CalculateRelativeWidgetBounds() static public méthode

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).
static public CalculateRelativeWidgetBounds ( Transform root, Transform child ) : Bounds
root Transform
child Transform
Résultat Bounds

CalculateRelativeWidgetBounds() static public méthode

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).
static public CalculateRelativeWidgetBounds ( Transform root, Transform child, bool considerInactive ) : Bounds
root Transform
child Transform
considerInactive bool
Résultat Bounds

CalculateRelativeWidgetBounds() static public méthode

Calculate the combined bounds of all widgets attached to the specified game object or its children (in relative-to-object space).
static public CalculateRelativeWidgetBounds ( Transform trans, bool considerInactive ) : Bounds
trans Transform
considerInactive bool
Résultat Bounds

ConstrainRect() static public méthode

Constrain 'rect' to be within 'area' as much as possible, returning the Vector2 offset necessary for this to happen. This function is useful when trying to restrict one area (window) to always be within another (viewport).
static public ConstrainRect ( Vector2 minRect, Vector2 maxRect, Vector2 minArea, Vector2 maxArea ) : Vector2
minRect Vector2
maxRect Vector2
minArea Vector2
maxArea Vector2
Résultat Vector2

ConvertToPixels() static public méthode

Convert from bottom-left based UV coordinates to top-left based pixel coordinates.
static public ConvertToPixels ( Rect rect, int width, int height, bool round ) : Rect
rect Rect
width int
height int
round bool
Résultat Rect

ConvertToTexCoords() static public méthode

Convert from top-left based pixel coordinates to bottom-left based UV coordinates.
static public ConvertToTexCoords ( Rect rect, int width, int height ) : Rect
rect Rect
width int
height int
Résultat Rect

DistanceToRectangle() static public méthode

Determine the distance from the mouse position to the screen space rectangle specified by the 4 points.
static public DistanceToRectangle ( Vector2 screenPoints, Vector2 mousePos ) : float
screenPoints Vector2
mousePos Vector2
Résultat float

DistanceToRectangle() static public méthode

Determine the distance from the mouse position to the world rectangle specified by the 4 points.
static public DistanceToRectangle ( Vector3 worldPoints, Vector2 mousePos, Camera cam ) : float
worldPoints Vector3
mousePos Vector2
cam Camera
Résultat float

GetPivot() static public méthode

Helper function that converts the pivot offset to a pivot point.
static public GetPivot ( Vector2 offset ) : UIWidget.Pivot
offset Vector2
Résultat UIWidget.Pivot

GetPivotOffset() static public méthode

Helper function that converts the widget's pivot enum into a 0-1 range vector.
static public GetPivotOffset ( UIWidget, pv ) : Vector2
pv UIWidget,
Résultat Vector2

MakePixelPerfect() static public méthode

Round the pixel rectangle's dimensions.
static public MakePixelPerfect ( Rect rect ) : Rect
rect Rect
Résultat Rect

MakePixelPerfect() static public méthode

Round the texture coordinate rectangle's dimensions.
static public MakePixelPerfect ( Rect rect, int width, int height ) : Rect
rect Rect
width int
height int
Résultat Rect

MoveRect() static public méthode

Adjust the rectangle's position using the specified local delta coordinates.
static public MoveRect ( UIRect, rect, float x, float y ) : void
rect UIRect,
x float
y float
Résultat void

MoveWidget() static public méthode

Adjust the widget's position using the specified local delta coordinates.
static public MoveWidget ( UIRect, w, float x, float y ) : void
w UIRect,
x float
y float
Résultat void

ResizeWidget() static public méthode

Given the specified dragged pivot point, adjust the widget's dimensions.
static public ResizeWidget ( UIWidget, w, UIWidget, pivot, float x, float y, int minWidth, int minHeight ) : void
w UIWidget,
pivot UIWidget,
x float
y float
minWidth int
minHeight int
Résultat void

ResizeWidget() static public méthode

Given the specified dragged pivot point, adjust the widget's dimensions.
static public ResizeWidget ( UIWidget, w, UIWidget, pivot, float x, float y, int minWidth, int minHeight, int maxWidth, int maxHeight ) : void
w UIWidget,
pivot UIWidget,
x float
y float
minWidth int
minHeight int
maxWidth int
maxHeight int
Résultat void

RotateTowards() static public méthode

Since there is no Mathf.RotateTowards...
static public RotateTowards ( float from, float to, float maxAngle ) : float
from float
to float
maxAngle float
Résultat float

SpringDampen() static public méthode

Same as the Vector3 version, it's a framerate-independent Lerp.
static public SpringDampen ( Vector2 &velocity, float strength, float deltaTime ) : Vector2
velocity Vector2
strength float
deltaTime float
Résultat Vector2

SpringDampen() static public méthode

This code is not framerate-independent: target.position += velocity; velocity = Vector3.Lerp(velocity, Vector3.zero, Time.deltaTime * 9f); But this code is: target.position += NGUIMath.SpringDampen(ref velocity, 9f, Time.deltaTime);
static public SpringDampen ( Vector3 &velocity, float strength, float deltaTime ) : Vector3
velocity Vector3
strength float
deltaTime float
Résultat Vector3

SpringLerp() static public méthode

Quaternion.Slerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.
static public SpringLerp ( Quaternion from, Quaternion to, float strength, float deltaTime ) : Quaternion
from Quaternion
to Quaternion
strength float
deltaTime float
Résultat Quaternion

SpringLerp() static public méthode

Vector2.Lerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.
static public SpringLerp ( Vector2 from, Vector2 to, float strength, float deltaTime ) : Vector2
from Vector2
to Vector2
strength float
deltaTime float
Résultat Vector2

SpringLerp() static public méthode

Vector3.Lerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.
static public SpringLerp ( Vector3 from, Vector3 to, float strength, float deltaTime ) : Vector3
from Vector3
to Vector3
strength float
deltaTime float
Résultat Vector3

SpringLerp() static public méthode

Calculate how much to interpolate by.
static public SpringLerp ( float strength, float deltaTime ) : float
strength float
deltaTime float
Résultat float

SpringLerp() static public méthode

Mathf.Lerp(from, to, Time.deltaTime * strength) is not framerate-independent. This function is.
static public SpringLerp ( float from, float to, float strength, float deltaTime ) : float
from float
to float
strength float
deltaTime float
Résultat float