C# Класс JCSUnity.JCS_Util

All the utility function put here.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddEventTriggerEvent ( EventTrigger te, EventTriggerType type, EventTriggerEvent func ) : void

Add Event to Unity's Event Trigger(Script)

AddEventTriggerEvent ( EventTrigger te, EventTriggerType type, EventTriggerEventButtonSelection func, JCSUnity.JCS_ButtonSelection selection ) : void

Add Event to Unity's Event Trigger(Script)

ApplyRandVector3 ( Vector3 trans, Vector3 randVec, JCS_Bool3 checks ) : Vector3

Add random value to Vector3

AttachChildren ( RectTransform trans, List childs ) : void
AttachChildren ( Transform trans, List childs ) : void

Attach all childs to this transform.

BytesToString ( Array data, JCS_CharsetType charset ) : string

Convert byte array to string by charset type.

CopyByteArray ( Array inBuf, int start, int len ) : byte[]

Copy byte array to another byte array memory space.

DeleteAllFilesFromDir ( string dirPath ) : void

Delete all files in directory.

DestroyAllTypeObjectInScene ( ) : void

Destroy all the 'TYPE' object in the scene.

DestroyImmediateAllTypeObjectInScene ( ) : void

Destroy all the 'TYPE' object in the scene.

DetachChildren ( RectTransform trans ) : List
DetachChildren ( Transform trans ) : List

Detttach all the child from one transform.

EnumSize ( ) : int

Return the length of an enumerator.

EscapeURL ( string url ) : string

Simple version of escape url.

FillSlot ( List inList, int len, with ) : List
FillSlot ( Array inArray, int len, with ) : T[]

Fill slots with initialize value type by length.

FindCloneObjectsOfTypeAll ( ) : T[]

Find all the objects that are clone in the scene by type.

FindNotCloneObjectsOfTypeAll ( ) : T[]

Find all the objects that are not clone in the scene by type.

FindObjectsOfTypeAllInHierarchy ( ) : T[]

Find all objects that only ACTIVE in hierarchy.

ForceDetachChildren ( RectTransform trans ) : List
ForceDetachChildren ( Transform trans ) : List

Force to clean all the children, this will make sure the transform have 0 children transform.

ForceGetComponent ( MonoBehaviour mb ) : T

Force to get a component, if not found we will add one then.

GetEasing ( JCS_TweenType type ) : TweenDelegate

Return the easing function pointer base on tweener type.

GetFinalLocalEulerAngles ( Transform trans, Vector3 &inEulerAngles ) : Vector3

Multiply all the parent localEulerAngles to get the correct description of the transform information. ATTENTION(jenchieh): This will cause some performance, use it wisely.

GetImageRect ( Image img ) : Vector2

Returns the size of the image.

GetSpriteRendererRect ( SpriteRenderer sr ) : Vector2

Returns the size of the sprite renderer.

GetSpriteRendererRectWithNoScale ( SpriteRenderer sr ) : Vector2

Returns the size of the sprite renderer without the scale value multiply.

GetValues ( ) : IEnumerable

Enum typed version casting. Source: http://stackoverflow.com/questions/972307/can-you-loop-through-all-enum-values

HasChild ( RectTransform trans ) : bool
HasChild ( Transform trans ) : bool

Return true, if transform has at least one children.

IncVec3 ( Vector3 val, float x, float y, float z ) : Vector3
IncVecX ( Vector3 val, float x ) : Vector3

Add the vector value.

IncVecY ( Vector3 val, float y ) : Vector3
IncVecZ ( Vector3 val, float z ) : Vector3
IsArrayEmpty ( Array list ) : bool

Check if the list empty.

IsNumberString ( string str ) : bool

Is the string the valid number to parse.

IsOverGUI ( ) : bool

Check if mosue is over any UI element.

IsSameTribe ( JCS_2DLiveObject liveObj1, JCS_2DLiveObject liveObj2 ) : bool

Check if the object are the same tribe.

IsScene ( string name ) : bool

Check current scene's with NAME.

LastFileIndex ( string path, string prefixStr, string ext ) : int

Method to do search directory and get the last file index.

ListPopBack ( List list ) : T

Pop the last value from the list.

ListPopFront ( List list ) : T

Pop the last value from the list.

LoopInArray ( int index, Array arr ) : int

Loop in an array. (Array)

LoopInArray ( int index, List arr ) : int

Loop in an array. (List)

MergeArrays ( ) : T[]

Merge multiple arrays into one array.

MergeArrays2 ( Array arr1, Array arr2 ) : T[]

Merging two array and return the new array.

MergeList ( ) : List

Merging two list and return the new list.

MouseOverGUI ( RectTransform imageRect, RectTransform rootPanel = null ) : bool

Solve the flash problem! (JCS_CheckableObject) Check if the mouse still on top of the image! ATTENTIOIN(jenchieh): this will not work on the resizable window.

MoveToTheLastChild ( Transform trans ) : void

Move the object to the last child of the Unty's tree system(Hierarchy) transform.

ReattachSelf ( RectTransform trans, ReattachCallback callback ) : void
ReattachSelf ( Transform trans, ReattachCallback callback ) : void

Execution callback after detach and reattach.

RemoveEmptySlot ( List inList ) : List
RemoveEmptySlot ( Array inArray ) : T[]

Remove the empty slot in the array.

RemoveEmptySlotIncludeMissing ( List inList ) : List
RemoveEmptySlotIncludeMissing ( Array inArray ) : T[]

Remove the empty slot in the list including remove the missing gameobject too. I guess Unity do the CG collection later a while when you call 'Destory()' function. Before scripting layer acknowledge this game object is destory might be too late in some situation. This will avoid this type of issue/circumstance.

SetActiveToAllChildren ( Transform trans, bool act ) : void

Active all the child in a transform.

SetEnableAllComponents ( Transform trans, bool act ) : void

Set eabled/disabled to all component in a transform.

SetParentWithoutLosingInfo ( Transform trans, Transform parent ) : void

Set the transform to onther transform in the hierarchy and without losing the info. Info: position, rotation, scale, etc.

SetVec3 ( Vector3 &val, float x, float y, float z ) : Vector3
SetVecX ( Vector3 &val, float x ) : Vector3

Set the vector value.

SetVecY ( Vector3 &val, float y ) : Vector3
SetVecZ ( Vector3 &val, float z ) : Vector3
SpawnAnimateObject ( RuntimeAnimatorController anim, int orderLayer = 15 ) : GameObject

Spawn an animate object.

SpawnAnimateObjectDeathEvent ( RuntimeAnimatorController anim, int orderLayer = 15, int loopTimes = 1 ) : GameObject

Spawn a animate object with the death event, so after the animate was played serval loop times the object will be destroyed.

SpawnGameObject ( string objectPath, Vector3 position = newVector3(), Quaternion rotation = newQuaternion() ) : GameObject

Spawn a gmae object.

SpawnGameObject ( Object trans, Vector3 position = newVector3(), Quaternion rotation = newQuaternion() ) : Object

Spawn a gmae object.

StringToBytes ( string data, JCS_CharsetType charset ) : byte[]

Convert string to byte array by charset type.

ToJson ( obj ) : string

Return JSON by passing serializable object.

VectorDirection ( JCS_Vector3Direction direction ) : Vector3

Return direction of Unity's Vector system.

WithInAcceptRange ( float range, float acceptRange, float currentVal ) : bool

Check the value within the range plus acceptable range.

WithInArrayRange ( int index, Array arr ) : bool

With in array range. (Array)

WithInArrayRange ( int index, List arr ) : bool

With in array range. (List)

WithInRange ( float minRange, float maxRange, float currentVal ) : bool

Check the value within the range.

Описание методов

AddEventTriggerEvent() публичный статический Метод

Add Event to Unity's Event Trigger(Script)
public static AddEventTriggerEvent ( EventTrigger te, EventTriggerType type, EventTriggerEvent func ) : void
te EventTrigger
type EventTriggerType
func EventTriggerEvent
Результат void

AddEventTriggerEvent() публичный статический Метод

Add Event to Unity's Event Trigger(Script)
public static AddEventTriggerEvent ( EventTrigger te, EventTriggerType type, EventTriggerEventButtonSelection func, JCSUnity.JCS_ButtonSelection selection ) : void
te EventTrigger
type EventTriggerType
func EventTriggerEventButtonSelection
selection JCSUnity.JCS_ButtonSelection
Результат void

ApplyRandVector3() публичный статический Метод

Add random value to Vector3
public static ApplyRandVector3 ( Vector3 trans, Vector3 randVec, JCS_Bool3 checks ) : Vector3
trans Vector3 transfrorm u want to apply.
randVec Vector3 value for each axis.
checks JCS_Bool3 check for eaxh axis.
Результат Vector3

AttachChildren() публичный статический Метод

public static AttachChildren ( RectTransform trans, List childs ) : void
trans RectTransform
childs List
Результат void

AttachChildren() публичный статический Метод

Attach all childs to this transform.
public static AttachChildren ( Transform trans, List childs ) : void
trans Transform transform we want to add the childs to.
childs List childs we want to add to transform.
Результат void

BytesToString() публичный статический Метод

Convert byte array to string by charset type.
public static BytesToString ( Array data, JCS_CharsetType charset ) : string
data Array Byte array data to convert to string data.
charset JCS_CharsetType Target charset type.
Результат string

CopyByteArray() публичный статический Метод

Copy byte array to another byte array memory space.
public static CopyByteArray ( Array inBuf, int start, int len ) : byte[]
inBuf Array byte array to copy.
start int Starting index to copy.
len int Length to copy.
Результат byte[]

DeleteAllFilesFromDir() публичный статический Метод

Delete all files in directory.
public static DeleteAllFilesFromDir ( string dirPath ) : void
dirPath string Target delete directory.
Результат void

DestroyAllTypeObjectInScene() публичный статический Метод

Destroy all the 'TYPE' object in the scene.
public static DestroyAllTypeObjectInScene ( ) : void
Результат void

DestroyImmediateAllTypeObjectInScene() публичный статический Метод

Destroy all the 'TYPE' object in the scene.
public static DestroyImmediateAllTypeObjectInScene ( ) : void
Результат void

DetachChildren() публичный статический Метод

public static DetachChildren ( RectTransform trans ) : List
trans RectTransform
Результат List

DetachChildren() публичный статический Метод

Detttach all the child from one transform.
public static DetachChildren ( Transform trans ) : List
trans Transform transform you want to remove all /// the children under.
Результат List

EnumSize() публичный статический Метод

Return the length of an enumerator.
public static EnumSize ( ) : int
Результат int

EscapeURL() публичный статический Метод

Simple version of escape url.
public static EscapeURL ( string url ) : string
url string Url you want to escape.
Результат string

FillSlot() публичный статический Метод

public static FillSlot ( List inList, int len, with ) : List
inList List
len int
Результат List

FillSlot() публичный статический Метод

Fill slots with initialize value type by length.
public static FillSlot ( Array inArray, int len, with ) : T[]
inArray Array Array you would like to fill out.
len int Target length to initialize.
with Initialize object type.
Результат T[]

FindCloneObjectsOfTypeAll() публичный статический Метод

Find all the objects that are clone in the scene by type.
public static FindCloneObjectsOfTypeAll ( ) : T[]
Результат T[]

FindNotCloneObjectsOfTypeAll() публичный статический Метод

Find all the objects that are not clone in the scene by type.
public static FindNotCloneObjectsOfTypeAll ( ) : T[]
Результат T[]

FindObjectsOfTypeAllInHierarchy() публичный статический Метод

Find all objects that only ACTIVE in hierarchy.
public static FindObjectsOfTypeAllInHierarchy ( ) : T[]
Результат T[]

ForceDetachChildren() публичный статический Метод

public static ForceDetachChildren ( RectTransform trans ) : List
trans RectTransform
Результат List

ForceDetachChildren() публичный статический Метод

Force to clean all the children, this will make sure the transform have 0 children transform.
public static ForceDetachChildren ( Transform trans ) : List
trans Transform transform you want to remove all /// the children under.
Результат List

ForceGetComponent() публичный статический Метод

Force to get a component, if not found we will add one then.
public static ForceGetComponent ( MonoBehaviour mb ) : T
mb MonoBehaviour Any MonoBehaviour.
Результат T

GetEasing() публичный статический Метод

Return the easing function pointer base on tweener type.
public static GetEasing ( JCS_TweenType type ) : TweenDelegate
type JCS_TweenType type of the tween formula
Результат TweenDelegate

GetFinalLocalEulerAngles() публичный статический Метод

Multiply all the parent localEulerAngles to get the correct description of the transform information. ATTENTION(jenchieh): This will cause some performance, use it wisely.
public static GetFinalLocalEulerAngles ( Transform trans, Vector3 &inEulerAngles ) : Vector3
trans Transform transform we want to get from and use /// it for parent.
inEulerAngles Vector3 use to store the result.
Результат Vector3

GetImageRect() публичный статический Метод

Returns the size of the image.
public static GetImageRect ( Image img ) : Vector2
img Image
Результат Vector2

GetSpriteRendererRect() публичный статический Метод

Returns the size of the sprite renderer.
public static GetSpriteRendererRect ( SpriteRenderer sr ) : Vector2
sr SpriteRenderer
Результат Vector2

GetSpriteRendererRectWithNoScale() публичный статический Метод

Returns the size of the sprite renderer without the scale value multiply.
public static GetSpriteRendererRectWithNoScale ( SpriteRenderer sr ) : Vector2
sr SpriteRenderer
Результат Vector2

GetValues() публичный статический Метод

Enum typed version casting. Source: http://stackoverflow.com/questions/972307/can-you-loop-through-all-enum-values
public static GetValues ( ) : IEnumerable
Результат IEnumerable

HasChild() публичный статический Метод

public static HasChild ( RectTransform trans ) : bool
trans RectTransform
Результат bool

HasChild() публичный статический Метод

Return true, if transform has at least one children.
public static HasChild ( Transform trans ) : bool
trans Transform
Результат bool

IncVec3() публичный статический Метод

public static IncVec3 ( Vector3 val, float x, float y, float z ) : Vector3
val Vector3
x float
y float
z float
Результат Vector3

IncVecX() публичный статический Метод

Add the vector value.
public static IncVecX ( Vector3 val, float x ) : Vector3
val Vector3
x float
Результат Vector3

IncVecY() публичный статический Метод

public static IncVecY ( Vector3 val, float y ) : Vector3
val Vector3
y float
Результат Vector3

IncVecZ() публичный статический Метод

public static IncVecZ ( Vector3 val, float z ) : Vector3
val Vector3
z float
Результат Vector3

IsArrayEmpty() публичный статический Метод

Check if the list empty.
public static IsArrayEmpty ( Array list ) : bool
list Array
Результат bool

IsNumberString() публичный статический Метод

Is the string the valid number to parse.
public static IsNumberString ( string str ) : bool
str string
Результат bool

IsOverGUI() публичный статический Метод

Check if mosue is over any UI element.
public static IsOverGUI ( ) : bool
Результат bool

IsSameTribe() публичный статический Метод

Check if the object are the same tribe.
public static IsSameTribe ( JCS_2DLiveObject liveObj1, JCS_2DLiveObject liveObj2 ) : bool
liveObj1 JCS_2DLiveObject obj one
liveObj2 JCS_2DLiveObject obj two
Результат bool

IsScene() публичный статический Метод

Check current scene's with NAME.
public static IsScene ( string name ) : bool
name string Name of the scene.
Результат bool

LastFileIndex() публичный статический Метод

Method to do search directory and get the last file index.
public static LastFileIndex ( string path, string prefixStr, string ext ) : int
path string path to search index.
prefixStr string Filen name prefix.
ext string Filen name extension.
Результат int

ListPopBack() публичный статический Метод

Pop the last value from the list.
public static ListPopBack ( List list ) : T
list List
Результат T

ListPopFront() публичный статический Метод

Pop the last value from the list.
public static ListPopFront ( List list ) : T
list List
Результат T

LoopInArray() публичный статический Метод

Loop in an array. (Array)
public static LoopInArray ( int index, Array arr ) : int
index int Index
arr Array Array.
Результат int

LoopInArray() публичный статический Метод

Loop in an array. (List)
public static LoopInArray ( int index, List arr ) : int
index int Index
arr List List.
Результат int

MergeArrays() публичный статический Метод

Merge multiple arrays into one array.
public static MergeArrays ( ) : T[]
Результат T[]

MergeArrays2() публичный статический Метод

Merging two array and return the new array.
public static MergeArrays2 ( Array arr1, Array arr2 ) : T[]
arr1 Array First array.
arr2 Array Second array.
Результат T[]

MergeList() публичный статический Метод

Merging two list and return the new list.
public static MergeList ( ) : List
Результат List

MouseOverGUI() публичный статический Метод

Solve the flash problem! (JCS_CheckableObject) Check if the mouse still on top of the image! ATTENTIOIN(jenchieh): this will not work on the resizable window.
public static MouseOverGUI ( RectTransform imageRect, RectTransform rootPanel = null ) : bool
imageRect RectTransform
rootPanel RectTransform
Результат bool

MoveToTheLastChild() публичный статический Метод

Move the object to the last child of the Unty's tree system(Hierarchy) transform.
public static MoveToTheLastChild ( Transform trans ) : void
trans Transform
Результат void

ReattachSelf() публичный статический Метод

public static ReattachSelf ( RectTransform trans, ReattachCallback callback ) : void
trans RectTransform
callback ReattachCallback
Результат void

ReattachSelf() публичный статический Метод

Execution callback after detach and reattach.
public static ReattachSelf ( Transform trans, ReattachCallback callback ) : void
trans Transform Transform you want to detach and reattach after callback.
callback ReattachCallback Callback after detach and before reattach.
Результат void

RemoveEmptySlot() публичный статический Метод

public static RemoveEmptySlot ( List inList ) : List
inList List
Результат List

RemoveEmptySlot() публичный статический Метод

Remove the empty slot in the array.
public static RemoveEmptySlot ( Array inArray ) : T[]
inArray Array Array list.
Результат T[]

RemoveEmptySlotIncludeMissing() публичный статический Метод

public static RemoveEmptySlotIncludeMissing ( List inList ) : List
inList List
Результат List

RemoveEmptySlotIncludeMissing() публичный статический Метод

Remove the empty slot in the list including remove the missing gameobject too. I guess Unity do the CG collection later a while when you call 'Destory()' function. Before scripting layer acknowledge this game object is destory might be too late in some situation. This will avoid this type of issue/circumstance.
public static RemoveEmptySlotIncludeMissing ( Array inArray ) : T[]
inArray Array
Результат T[]

SetActiveToAllChildren() публичный статический Метод

Active all the child in a transform.
public static SetActiveToAllChildren ( Transform trans, bool act ) : void
trans Transform transform to do the effect.
act bool action to the effect
Результат void

SetEnableAllComponents() публичный статический Метод

Set eabled/disabled to all component in a transform.
public static SetEnableAllComponents ( Transform trans, bool act ) : void
trans Transform transform to apply the effect.
act bool enable or disable?
Результат void

SetParentWithoutLosingInfo() публичный статический Метод

Set the transform to onther transform in the hierarchy and without losing the info. Info: position, rotation, scale, etc.
public static SetParentWithoutLosingInfo ( Transform trans, Transform parent ) : void
trans Transform transform to set to parent transform
parent Transform parent transform
Результат void

SetVec3() публичный статический Метод

public static SetVec3 ( Vector3 &val, float x, float y, float z ) : Vector3
val Vector3
x float
y float
z float
Результат Vector3

SetVecX() публичный статический Метод

Set the vector value.
public static SetVecX ( Vector3 &val, float x ) : Vector3
val Vector3
x float
Результат Vector3

SetVecY() публичный статический Метод

public static SetVecY ( Vector3 &val, float y ) : Vector3
val Vector3
y float
Результат Vector3

SetVecZ() публичный статический Метод

public static SetVecZ ( Vector3 &val, float z ) : Vector3
val Vector3
z float
Результат Vector3

SpawnAnimateObject() публичный статический Метод

Spawn an animate object.
public static SpawnAnimateObject ( RuntimeAnimatorController anim, int orderLayer = 15 ) : GameObject
anim RuntimeAnimatorController anim assign
orderLayer int sorting order
Результат GameObject

SpawnAnimateObjectDeathEvent() публичный статический Метод

Spawn a animate object with the death event, so after the animate was played serval loop times the object will be destroyed.
public static SpawnAnimateObjectDeathEvent ( RuntimeAnimatorController anim, int orderLayer = 15, int loopTimes = 1 ) : GameObject
anim RuntimeAnimatorController animation u want to play
orderLayer int sorting order
loopTimes int loop times
Результат GameObject

SpawnGameObject() публичный статический Метод

Spawn a gmae object.
public static SpawnGameObject ( string objectPath, Vector3 position = newVector3(), Quaternion rotation = newQuaternion() ) : GameObject
objectPath string path of the game object
position Vector3 position of the game object spawn
rotation Quaternion rotation of the game object spawn
Результат GameObject

SpawnGameObject() публичный статический Метод

Spawn a gmae object.
public static SpawnGameObject ( Object trans, Vector3 position = newVector3(), Quaternion rotation = newQuaternion() ) : Object
trans UnityEngine.Object
position Vector3
rotation Quaternion
Результат UnityEngine.Object

StringToBytes() публичный статический Метод

Convert string to byte array by charset type.
public static StringToBytes ( string data, JCS_CharsetType charset ) : byte[]
data string String data to convert to byte array.
charset JCS_CharsetType Target charset type.
Результат byte[]

ToJson() публичный статический Метод

Return JSON by passing serializable object.
public static ToJson ( obj ) : string
obj Object that are serializable.
Результат string

VectorDirection() публичный статический Метод

Return direction of Unity's Vector system.
public static VectorDirection ( JCS_Vector3Direction direction ) : Vector3
direction JCS_Vector3Direction direction u wants.
Результат Vector3

WithInAcceptRange() публичный статический Метод

Check the value within the range plus acceptable range.
public static WithInAcceptRange ( float range, float acceptRange, float currentVal ) : bool
range float
acceptRange float
currentVal float
Результат bool

WithInArrayRange() публичный статический Метод

With in array range. (Array)
public static WithInArrayRange ( int index, Array arr ) : bool
index int
arr Array
Результат bool

WithInArrayRange() публичный статический Метод

With in array range. (List)
public static WithInArrayRange ( int index, List arr ) : bool
index int
arr List
Результат bool

WithInRange() публичный статический Метод

Check the value within the range.
public static WithInRange ( float minRange, float maxRange, float currentVal ) : bool
minRange float
maxRange float
currentVal float
Результат bool