Show / Hide Table of Contents

Class Util

Util static methods for Votanic project development.
Votanic 項目開發實用的靜態方法。

Inheritance
System.Object
Util
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
參考 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
當 true 時 LAYERS 參數內的層級指數將會忽略

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
Raycast 將會根據 Detect Layers 的順序檢查

System.Boolean ignoreLayers

The layer indices in LAYERS parameter will be ignored if true
當 true 時 LAYERS 參數內的層級指數將會忽略

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
當 true 時 LAYERS 參數內的層級指數將會忽略

System.Int32[] layers

The layer indices
層級指數

Returns
Type Description
UnityEngine.RaycastHit[]
In This Article
Back to top Generated by DocFX