C# Class JCSUnity.JCS_Util

All the utility function put here.
Show file Open project: MapleStoryUnity/MapleStoryUnity Class Usage Examples

Public Methods

Method Description
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.

Method Details

AddEventTriggerEvent() public static method

Add Event to Unity's Event Trigger(Script)
public static AddEventTriggerEvent ( EventTrigger te, EventTriggerType type, EventTriggerEvent func ) : void
te EventTrigger
type EventTriggerType
func EventTriggerEvent
return void

AddEventTriggerEvent() public static method

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
return void

ApplyRandVector3() public static method

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.
return Vector3

AttachChildren() public static method

public static AttachChildren ( RectTransform trans, List childs ) : void
trans RectTransform
childs List
return void

AttachChildren() public static method

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.
return void

BytesToString() public static method

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.
return string

CopyByteArray() public static method

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.
return byte[]

DeleteAllFilesFromDir() public static method

Delete all files in directory.
public static DeleteAllFilesFromDir ( string dirPath ) : void
dirPath string Target delete directory.
return void

DestroyAllTypeObjectInScene() public static method

Destroy all the 'TYPE' object in the scene.
public static DestroyAllTypeObjectInScene ( ) : void
return void

DestroyImmediateAllTypeObjectInScene() public static method

Destroy all the 'TYPE' object in the scene.
public static DestroyImmediateAllTypeObjectInScene ( ) : void
return void

DetachChildren() public static method

public static DetachChildren ( RectTransform trans ) : List
trans RectTransform
return List

DetachChildren() public static method

Detttach all the child from one transform.
public static DetachChildren ( Transform trans ) : List
trans Transform transform you want to remove all /// the children under.
return List

EnumSize() public static method

Return the length of an enumerator.
public static EnumSize ( ) : int
return int

EscapeURL() public static method

Simple version of escape url.
public static EscapeURL ( string url ) : string
url string Url you want to escape.
return string

FillSlot() public static method

public static FillSlot ( List inList, int len, with ) : List
inList List
len int
return List

FillSlot() public static method

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.
return T[]

FindCloneObjectsOfTypeAll() public static method

Find all the objects that are clone in the scene by type.
public static FindCloneObjectsOfTypeAll ( ) : T[]
return T[]

FindNotCloneObjectsOfTypeAll() public static method

Find all the objects that are not clone in the scene by type.
public static FindNotCloneObjectsOfTypeAll ( ) : T[]
return T[]

FindObjectsOfTypeAllInHierarchy() public static method

Find all objects that only ACTIVE in hierarchy.
public static FindObjectsOfTypeAllInHierarchy ( ) : T[]
return T[]

ForceDetachChildren() public static method

public static ForceDetachChildren ( RectTransform trans ) : List
trans RectTransform
return List

ForceDetachChildren() public static method

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.
return List

ForceGetComponent() public static method

Force to get a component, if not found we will add one then.
public static ForceGetComponent ( MonoBehaviour mb ) : T
mb MonoBehaviour Any MonoBehaviour.
return T

GetEasing() public static method

Return the easing function pointer base on tweener type.
public static GetEasing ( JCS_TweenType type ) : TweenDelegate
type JCS_TweenType type of the tween formula
return TweenDelegate

GetFinalLocalEulerAngles() public static method

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.
return Vector3

GetImageRect() public static method

Returns the size of the image.
public static GetImageRect ( Image img ) : Vector2
img Image
return Vector2

GetSpriteRendererRect() public static method

Returns the size of the sprite renderer.
public static GetSpriteRendererRect ( SpriteRenderer sr ) : Vector2
sr SpriteRenderer
return Vector2

GetSpriteRendererRectWithNoScale() public static method

Returns the size of the sprite renderer without the scale value multiply.
public static GetSpriteRendererRectWithNoScale ( SpriteRenderer sr ) : Vector2
sr SpriteRenderer
return Vector2

GetValues() public static method

Enum typed version casting. Source: http://stackoverflow.com/questions/972307/can-you-loop-through-all-enum-values
public static GetValues ( ) : IEnumerable
return IEnumerable

HasChild() public static method

public static HasChild ( RectTransform trans ) : bool
trans RectTransform
return bool

HasChild() public static method

Return true, if transform has at least one children.
public static HasChild ( Transform trans ) : bool
trans Transform
return bool

IncVec3() public static method

public static IncVec3 ( Vector3 val, float x, float y, float z ) : Vector3
val Vector3
x float
y float
z float
return Vector3

IncVecX() public static method

Add the vector value.
public static IncVecX ( Vector3 val, float x ) : Vector3
val Vector3
x float
return Vector3

IncVecY() public static method

public static IncVecY ( Vector3 val, float y ) : Vector3
val Vector3
y float
return Vector3

IncVecZ() public static method

public static IncVecZ ( Vector3 val, float z ) : Vector3
val Vector3
z float
return Vector3

IsArrayEmpty() public static method

Check if the list empty.
public static IsArrayEmpty ( Array list ) : bool
list Array
return bool

IsNumberString() public static method

Is the string the valid number to parse.
public static IsNumberString ( string str ) : bool
str string
return bool

IsOverGUI() public static method

Check if mosue is over any UI element.
public static IsOverGUI ( ) : bool
return bool

IsSameTribe() public static method

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
return bool

IsScene() public static method

Check current scene's with NAME.
public static IsScene ( string name ) : bool
name string Name of the scene.
return bool

LastFileIndex() public static method

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.
return int

ListPopBack() public static method

Pop the last value from the list.
public static ListPopBack ( List list ) : T
list List
return T

ListPopFront() public static method

Pop the last value from the list.
public static ListPopFront ( List list ) : T
list List
return T

LoopInArray() public static method

Loop in an array. (Array)
public static LoopInArray ( int index, Array arr ) : int
index int Index
arr Array Array.
return int

LoopInArray() public static method

Loop in an array. (List)
public static LoopInArray ( int index, List arr ) : int
index int Index
arr List List.
return int

MergeArrays() public static method

Merge multiple arrays into one array.
public static MergeArrays ( ) : T[]
return T[]

MergeArrays2() public static method

Merging two array and return the new array.
public static MergeArrays2 ( Array arr1, Array arr2 ) : T[]
arr1 Array First array.
arr2 Array Second array.
return T[]

MergeList() public static method

Merging two list and return the new list.
public static MergeList ( ) : List
return List

MouseOverGUI() public static method

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
return bool

MoveToTheLastChild() public static method

Move the object to the last child of the Unty's tree system(Hierarchy) transform.
public static MoveToTheLastChild ( Transform trans ) : void
trans Transform
return void

ReattachSelf() public static method

public static ReattachSelf ( RectTransform trans, ReattachCallback callback ) : void
trans RectTransform
callback ReattachCallback
return void

ReattachSelf() public static method

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.
return void

RemoveEmptySlot() public static method

public static RemoveEmptySlot ( List inList ) : List
inList List
return List

RemoveEmptySlot() public static method

Remove the empty slot in the array.
public static RemoveEmptySlot ( Array inArray ) : T[]
inArray Array Array list.
return T[]

RemoveEmptySlotIncludeMissing() public static method

public static RemoveEmptySlotIncludeMissing ( List inList ) : List
inList List
return List

RemoveEmptySlotIncludeMissing() public static method

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
return T[]

SetActiveToAllChildren() public static method

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
return void

SetEnableAllComponents() public static method

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?
return void

SetParentWithoutLosingInfo() public static method

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
return void

SetVec3() public static method

public static SetVec3 ( Vector3 &val, float x, float y, float z ) : Vector3
val Vector3
x float
y float
z float
return Vector3

SetVecX() public static method

Set the vector value.
public static SetVecX ( Vector3 &val, float x ) : Vector3
val Vector3
x float
return Vector3

SetVecY() public static method

public static SetVecY ( Vector3 &val, float y ) : Vector3
val Vector3
y float
return Vector3

SetVecZ() public static method

public static SetVecZ ( Vector3 &val, float z ) : Vector3
val Vector3
z float
return Vector3

SpawnAnimateObject() public static method

Spawn an animate object.
public static SpawnAnimateObject ( RuntimeAnimatorController anim, int orderLayer = 15 ) : GameObject
anim RuntimeAnimatorController anim assign
orderLayer int sorting order
return GameObject

SpawnAnimateObjectDeathEvent() public static method

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
return GameObject

SpawnGameObject() public static method

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
return GameObject

SpawnGameObject() public static method

Spawn a gmae object.
public static SpawnGameObject ( Object trans, Vector3 position = newVector3(), Quaternion rotation = newQuaternion() ) : Object
trans UnityEngine.Object
position Vector3
rotation Quaternion
return UnityEngine.Object

StringToBytes() public static method

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.
return byte[]

ToJson() public static method

Return JSON by passing serializable object.
public static ToJson ( obj ) : string
obj Object that are serializable.
return string

VectorDirection() public static method

Return direction of Unity's Vector system.
public static VectorDirection ( JCS_Vector3Direction direction ) : Vector3
direction JCS_Vector3Direction direction u wants.
return Vector3

WithInAcceptRange() public static method

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
return bool

WithInArrayRange() public static method

With in array range. (Array)
public static WithInArrayRange ( int index, Array arr ) : bool
index int
arr Array
return bool

WithInArrayRange() public static method

With in array range. (List)
public static WithInArrayRange ( int index, List arr ) : bool
index int
arr List
return bool

WithInRange() public static method

Check the value within the range.
public static WithInRange ( float minRange, float maxRange, float currentVal ) : bool
minRange float
maxRange float
currentVal float
return bool