Skip to content

Commit 3c65506

Browse files
committed
docs: Update
1 parent 9970a13 commit 3c65506

File tree

4 files changed

+102
-99
lines changed

4 files changed

+102
-99
lines changed

Assets/JCSUnity/Scripts/IO/JCS_IO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static bool CreateDirectory(string path)
129129
/// <returns></returns>
130130
public static int LastFileIndex(string path, string prefixStr, string ext)
131131
{
132-
JCS_IO.CreateDirectory(path);
132+
CreateDirectory(path);
133133

134134
var gs = JCS_GameSettings.instance;
135135

Assets/JCSUnity/Scripts/Util/JCS_Util.cs

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -343,59 +343,6 @@ public static T ListPopBack<T>(List<T> list)
343343

344344
#endregion
345345

346-
#region JSON
347-
348-
/// <summary>
349-
/// Return JSON by passing serializable object.
350-
/// </summary>
351-
/// <param name="obj"> Object that are serializable. </param>
352-
/// <returns> JSON string. </returns>
353-
public static string ToJson<T>(T obj)
354-
{
355-
return JsonUtility.ToJson(obj);
356-
}
357-
358-
#endregion
359-
360-
#region Scene
361-
362-
/// <summary>
363-
/// Check current scene's with NAME.
364-
/// </summary>
365-
/// <param name="name"> Name of the scene. </param>
366-
/// <returns>
367-
/// Return true, if the current scene name the same as NAME.
368-
/// Return false, if the current scene name NOT the same as NAME.
369-
/// </returns>
370-
public static bool IsScene(string name)
371-
{
372-
return SceneManager.GetActiveScene().name == name;
373-
}
374-
375-
/// <summary>
376-
/// Returns true if the scene 'name' exists and is in your Build settings,
377-
/// false otherwise.
378-
/// </summary>
379-
public static bool IsSceneExists(string name)
380-
{
381-
if (string.IsNullOrEmpty(name))
382-
return false;
383-
384-
for (int index = 0; index < SceneManager.sceneCountInBuildSettings; ++index)
385-
{
386-
var scenePath = SceneUtility.GetScenePathByBuildIndex(index);
387-
var lastSlash = scenePath.LastIndexOf("/");
388-
var sceneName = scenePath.Substring(lastSlash + 1, scenePath.LastIndexOf(".") - lastSlash - 1);
389-
390-
if (string.Compare(name, sceneName, true) == 0)
391-
return true;
392-
}
393-
394-
return false;
395-
}
396-
397-
#endregion
398-
399346
#region String
400347

401348
/// <summary>
@@ -455,6 +402,20 @@ public static string EscapeURL(string url)
455402

456403
#endregion
457404

405+
#region JSON
406+
407+
/// <summary>
408+
/// Return JSON by passing serializable object.
409+
/// </summary>
410+
/// <param name="obj"> Object that are serializable. </param>
411+
/// <returns> JSON string. </returns>
412+
public static string ToJson<T>(T obj)
413+
{
414+
return JsonUtility.ToJson(obj);
415+
}
416+
417+
#endregion
418+
458419
/// <summary>
459420
/// Do enable/distance component.
460421
/// </summary>
@@ -689,25 +650,6 @@ public static void SetParentWithoutLosingInfo(Transform trans, Transform parent)
689650
trans.localRotation = recordRot;
690651
}
691652

692-
/// <summary>
693-
/// Check if the object are the same tribe.
694-
/// </summary>
695-
/// <param name="liveObj1"> obj one </param>
696-
/// <param name="liveObj2"> obj two </param>
697-
/// <returns>
698-
/// true: same tribe
699-
/// false: not the same tribe
700-
/// </returns>
701-
public static bool IsSameTribe(JCS_2DLiveObject liveObj1, JCS_2DLiveObject liveObj2)
702-
{
703-
if (liveObj1 == null || liveObj2 == null)
704-
return false;
705-
706-
// if both player does not need to add in to list.
707-
// or if both enemy does not need to add in to list.
708-
return (liveObj1.IsPlayer == liveObj2.IsPlayer);
709-
}
710-
711653
/// <summary>
712654
/// Set eabled/disabled to all component in a transform.
713655
/// </summary>
@@ -1199,5 +1141,63 @@ public static void ReattachSelf(RectTransform trans, ReattachCallback callback)
11991141

12001142
trans.SetParent(parent);
12011143
}
1144+
1145+
#region Scene
1146+
1147+
/// <summary>
1148+
/// Check current scene's with NAME.
1149+
/// </summary>
1150+
/// <param name="name"> Name of the scene. </param>
1151+
/// <returns>
1152+
/// Return true, if the current scene name the same as NAME.
1153+
/// Return false, if the current scene name NOT the same as NAME.
1154+
/// </returns>
1155+
public static bool IsScene(string name)
1156+
{
1157+
return SceneManager.GetActiveScene().name == name;
1158+
}
1159+
1160+
/// <summary>
1161+
/// Returns true if the scene 'name' exists and is in your Build settings,
1162+
/// false otherwise.
1163+
/// </summary>
1164+
public static bool IsSceneExists(string name)
1165+
{
1166+
if (string.IsNullOrEmpty(name))
1167+
return false;
1168+
1169+
for (int index = 0; index < SceneManager.sceneCountInBuildSettings; ++index)
1170+
{
1171+
var scenePath = SceneUtility.GetScenePathByBuildIndex(index);
1172+
var lastSlash = scenePath.LastIndexOf("/");
1173+
var sceneName = scenePath.Substring(lastSlash + 1, scenePath.LastIndexOf(".") - lastSlash - 1);
1174+
1175+
if (string.Compare(name, sceneName, true) == 0)
1176+
return true;
1177+
}
1178+
1179+
return false;
1180+
}
1181+
1182+
#endregion
1183+
1184+
/// <summary>
1185+
/// Check if the object are the same tribe.
1186+
/// </summary>
1187+
/// <param name="liveObj1"> obj one </param>
1188+
/// <param name="liveObj2"> obj two </param>
1189+
/// <returns>
1190+
/// true: same tribe
1191+
/// false: not the same tribe
1192+
/// </returns>
1193+
public static bool IsSameTribe(JCS_2DLiveObject liveObj1, JCS_2DLiveObject liveObj2)
1194+
{
1195+
if (liveObj1 == null || liveObj2 == null)
1196+
return false;
1197+
1198+
// if both player does not need to add in to list.
1199+
// or if both enemy does not need to add in to list.
1200+
return (liveObj1.IsPlayer == liveObj2.IsPlayer);
1201+
}
12021202
}
12031203
}

docs/ScriptReference/IO/JCS_IO.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ IO utilities.
44

55
## Functions
66

7-
| Name | Description |
8-
|:------------------------|:-----------------------------------------------|
9-
| IsDirectory | Check if the path is a directory. |
10-
| IsFile | Check if the path is a file. |
11-
| IsFileState | Check if the path is the file attribute state. |
12-
| IsFileOrDirectoryExists | Check if path either directory or file exists. |
7+
| Name | Description |
8+
|:------------------------|:-----------------------------------------------------------|
9+
| IsDirectory | Check if the path is a directory. |
10+
| IsFile | Check if the path is a file. |
11+
| IsFileState | Check if the path is the file attribute state. |
12+
| IsFileOrDirectoryExists | Check if path either directory or file exists. |
13+
| LastFileIndex | Method to do search directory and get the last file index. |
14+
| DeleteAllFilesFromDir | Delete all files in directory. |

docs/ScriptReference/Util/JCS_Util.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,36 @@ All code utility is stored here.
66

77
| Name | Description |
88
|:-------------------------------------|:--------------------------------------------------------------------------------------------------|
9+
| IsNumberString | Check if the string is a number string. |
10+
| Parse | Parse `str` to integer, return `defaultValue` if failed. |
11+
| Parse | Parse `str` to float, return `defaultValue` if failed. |
12+
| Parse | Parse `str` to boolean, return `defaultValue` if failed. |
13+
| GetValues | Get the value for each enum, use to loop through the enum. |
14+
| EnumSize | Returns the length of an enumerator. |
15+
| WithInRange | Check if the value is within the range. |
16+
| WithInRange | Check if the index valid within the array length. |
17+
| LoopIn | Make the index is within the array length by setting the maxinum of (legnth - 1) or mininum of 0. |
18+
| MergeArrays | Merge multiple arrays into one array. |
19+
| MergeArrays2 | Merge two array and return the new array. |
20+
| MergeList | Merge the two lists and return the new list. |
21+
| CopyBtyeArray | Copy byte array to another byte array memory space. |
22+
| IsArrayEmpty | Check if the string array is empty. |
23+
| ListPopFront | Pop the first value from the list. |
24+
| ListPopBack | Pop the last value from the list. |
25+
| BytesToString | Convert byte array to string by charset type. |
26+
| StringToBytes | Convert string to byte array by charset type. |
27+
| EscapeURL | Simple version of escape url. |
28+
| ToJson | Serialize object to JSON string. |
929
| EnableComponent | Do enable/distance component. |
1030
| ForceGetComponent | Force to get a component, if not found add one new then. |
1131
| Instantiate | Spawn a game object. |
1232
| FindObjectByType | Retrieves the first active loaded object of Type type. |
1333
| FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
14-
| WithInRange | Check if the value is within the range. |
15-
| WithInRange | Check if the index valid within the array length. |
16-
| LoopIn | Make the index is within the array length by setting the maxinum of (legnth - 1) or mininum of 0. |
1734
| SpawnAnimateObject | Spawn a gameobject with animation attached. |
1835
| SpawnAnimateObjectDeathEvent | Spawn a gameobject with the animator and death event on it. |
1936
| SetActiveToAllChildren | Active all the child in a transform. |
2037
| MoveToTheLastChild | Make the transform to the last transform of the current parent transform. |
2138
| SetParentWithoutLosingInfo | Set the transform to another transform without losing it's info. (position, rotation, scale) |
22-
| IsSameTribe | Check if the live object is the same tribe. |
23-
| GetValues | Get the value for each enum, use to loop through the enum. |
2439
| SetEnableAllComponents | Set enable/disable to all component on this transform. |
2540
| DestroyAllTypeObjectInScene | Destory all gameobjects in the scene with the type passed in. |
2641
| DestroyImmediateAllTypeObjectInScene | Destroy all the gameobject in the scene immediately with the type passed in. |
@@ -31,23 +46,9 @@ All code utility is stored here.
3146
| FillSlot | Fill slots with initialize value type by length. |
3247
| RemoveEmptySlot | Remove the null value from a list/array. |
3348
| RemoveEmptySlotIncludeMissing | Remove all the null value including missing reference in the list/array. |
34-
| MergeArrays | Merge multiple arrays into one array. |
35-
| MergeArrays2 | Merge two array and return the new array. |
36-
| MergeList | Merge the two lists and return the new list. |
37-
| CopyBtyeArray | Copy byte array to another byte array memory space. |
38-
| EnumSize | Returns the length of an enumerator. |
39-
| IsArrayEmpty | Check if the string array is empty. |
40-
| ListPopFront | Pop the first value from the list. |
41-
| ListPopBack | Pop the last value from the list. |
42-
| IsNumberString | Check if the string is a number string. |
4349
| DetachChildren | Detach all the child from a transform. |
4450
| ForceDetachChildren | Force detach all the child from a transform. |
4551
| AttachChildren | Attach all the childs to this transform. |
46-
| ToJson | Serialize object to JSON string. |
4752
| IsScene | Check current scene's with NAME. |
4853
| IsSceneExists | Returns true if the scene 'name' exists and is in your Build settings, false otherwise. |
49-
| LastFileIndex | Method to do search directory and get the last file index. |
50-
| DeleteAllFilesFromDir | Delete all files in directory. |
51-
| BytesToString | Convert byte array to string by charset type. |
52-
| StringToBytes | Convert string to byte array by charset type. |
53-
| EscapeURL | Simple version of escape url. |
54+
| IsSameTribe | Check if the live object is the same tribe. |

0 commit comments

Comments
 (0)