Class Util
Util static methods for Votanic project development.
Votanic 項目開發實用的靜態方法。
Inheritance
Namespace: Votanic
Assembly: Votanic.Core.dll
Syntax
public class Util
Methods
ColorToTexture(Int32, Int32, Color)
Return a Texture2D from color.
由顏色傳回 Texture2D。
ColorToTexture(128, 128, Color.white)
Declaration
public static Texture2D ColorToTexture(int width, int height, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | width | Texture width |
System.Int32 | height | Texture height |
UnityEngine.Color | color | Target color |
Returns
Type | Description |
---|---|
UnityEngine.Texture2D |
CopyComponent<T>(T, GameObject)
Copy component to another gameobject.
複製組件至另一個物件。
CopyComponent<Rigidbody>(oldRigidbody, newGameObject)
Declaration
public static T CopyComponent<T>(T original, GameObject destination)
where T : Component
Parameters
Type | Name | Description |
---|---|---|
T | original | Component |
UnityEngine.GameObject | destination | Target object |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Component type |
HorizontalForward(Transform)
Return the horizontal forward direction of a transform.
傳回一個 Transform 的水平前方方向。
HorizontalForward(transform)
Declaration
public static Vector3 HorizontalForward(Transform transform)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Transform | transform | Reference transform |
Returns
Type | Description |
---|---|
UnityEngine.Vector3 |
HorizontalLookAt(Transform, Vector3, Boolean)
Look at a target horizontally.
水平望向一個目標。
HorizontalLookAt(observer, target)
Declaration
public static void HorizontalLookAt(Transform observer, Vector3 target, bool reverse = false)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Transform | observer | The observer |
UnityEngine.Vector3 | target | Target point |
System.Boolean | reverse | Reverse direction |
Layers(Boolean, Int32[])
Return the LayerMask from integer array.
由整數組傳回 LayerMask。
Layers("true", 30, 31)
Declaration
public static LayerMask Layers(bool ignoreLayers = false, params int[] layers)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | ignoreLayers | The layer indices in LAYERS parameter will be ignored if true |
System.Int32[] | layers | The layer indices |
Returns
Type | Description |
---|---|
UnityEngine.LayerMask |
Raycast(Vector3, Vector3, Single, Boolean, Boolean, Int32[])
Return the RaycastHit from a position and direction.
由某個位置及方向傳回 RaycastHit。
Raycast(transform.position, transform.forward, 3, true, 31)
Declaration
public static RaycastHit Raycast(Vector3 origin, Vector3 direction, float length = InfinityF, bool withPriority = false, bool ignoreLayers = false, params int[] layers)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | origin | Start position |
UnityEngine.Vector3 | direction | Ray direction |
System.Single | length | Ray length |
System.Boolean | withPriority | The raycast will be checked by the order of Detect Layers |
System.Boolean | ignoreLayers | The layer indices in LAYERS parameter will be ignored if true |
System.Int32[] | layers | The layer indices |
Returns
Type | Description |
---|---|
UnityEngine.RaycastHit |
RaycastAll(Vector3, Vector3, Single, Boolean, Int32[])
Return a group of RaycastHit from a position and direction.
由某個位置及方向傳回一組 RaycastHit。
RaycastAll(transform.position, transform.forward, 3, true, 31)
Declaration
public static RaycastHit[] RaycastAll(Vector3 origin, Vector3 direction, float length = InfinityF, bool ignoreLayers = false, params int[] layers)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | origin | Start position |
UnityEngine.Vector3 | direction | Ray direction |
System.Single | length | Ray length |
System.Boolean | ignoreLayers | The layer indices in LAYERS parameter will be ignored if true |
System.Int32[] | layers | The layer indices |
Returns
Type | Description |
---|---|
UnityEngine.RaycastHit[] |