Wanzyee Studio

Extension methods for UnityEngine.Component. More...

Static Public Member Functions

static string GetPath (this Component component, string separator="/")
 Get the hierarchy path, used for log or GameObject.Find() with the default separator. More...
 
static int GetIndex (this Component component)
 Get the component sibling index on the attaching UnityEngine.GameObject. More...
 
static Quaternion TransformQuat (this Transform transform, Quaternion rotation)
 Transforms rotation from local space to world space. More...
 
static Quaternion InverseTransformQuat (this Transform transform, Quaternion rotation)
 Transforms position from world space to local space, opposite of TransformQuat(). More...
 
static void SetCentimeterDragThreshold (this EventSystem eventSystem, float centimeter=0.3f, float fallbackDpi=200f)
 Set the drag threshold by centimeter for different resolution. More...
 
static Vector2 CenterToScreenPoint (this RectTransform transform)
 Convert the center of a specified UnityEngine.RectTransform to screen space point. More...
 
static void SetSorting (this Component component, int order)
 Set the sorting order of the UI element inside a UnityEngine.Canvas. More...
 

Detailed Description

Extension methods for UnityEngine.Component.

Member Function Documentation

static string GetPath ( this Component  component,
string  separator = "/" 
)
static

Get the hierarchy path, used for log or GameObject.Find() with the default separator.

Parameters
componentComponent.
separatorSeparator.
Returns
The hierarchy path.
static int GetIndex ( this Component  component)
static

Get the component sibling index on the attaching UnityEngine.GameObject.

Parameters
componentComponent.
Returns
The sibling index.
static Quaternion TransformQuat ( this Transform  transform,
Quaternion  rotation 
)
static

Transforms rotation from local space to world space.

Parameters
transformTransform.
rotationLocal rotation.
Returns
The world rotation.
static Quaternion InverseTransformQuat ( this Transform  transform,
Quaternion  rotation 
)
static

Transforms position from world space to local space, opposite of TransformQuat().

Parameters
transformTransform.
rotationWorld rotation.
Returns
The local rotation.
static void SetCentimeterDragThreshold ( this EventSystem  eventSystem,
float  centimeter = 0.3f,
float  fallbackDpi = 200f 
)
static

Set the drag threshold by centimeter for different resolution.

Parameters
eventSystemThe UnityEngine.EventSystems.EventSystem.
centimeterCentimeter.
fallbackDpiThe fallback DPI used when failed to fetch.
static Vector2 CenterToScreenPoint ( this RectTransform  transform)
static

Convert the center of a specified UnityEngine.RectTransform to screen space point.

Parameters
transformTransform.
Returns
The screen point.
static void SetSorting ( this Component  component,
int  order 
)
static

Set the sorting order of the UI element inside a UnityEngine.Canvas.

This only apply the sub canvas in a root canvas. Check to add it with UnityEngine.UI.GraphicRaycaster if not existing.

Parameters
componentComponent.
orderSorting order.