Skip to content

Commit 56e0e72

Browse files
committed
doc: update
1 parent 0360173 commit 56e0e72

File tree

2 files changed

+63
-61
lines changed

2 files changed

+63
-61
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Util.cs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,60 +28,6 @@ namespace JCSUnity
2828
/// </summary>
2929
public static class JCS_Util
3030
{
31-
#region Parse
32-
33-
/// <summary>
34-
/// Is the string the valid number to parse.
35-
/// </summary>
36-
/// <param name="str"></param>
37-
/// <returns></returns>
38-
public static bool IsNumberString(string str)
39-
{
40-
double test;
41-
return (double.TryParse(str, out test));
42-
}
43-
44-
/// <summary>
45-
/// Parse `str` to integer, return `defaultValue` if failed.
46-
/// </summary>
47-
public static int Parse(string str, int defaultValue)
48-
{
49-
int result;
50-
51-
if (int.TryParse(str, out result))
52-
return int.Parse(str);
53-
54-
return defaultValue;
55-
}
56-
57-
/// <summary>
58-
/// Parse `str` to float, return `defaultValue` if failed.
59-
/// </summary>
60-
public static float Parse(string str, float defaultValue)
61-
{
62-
float result;
63-
64-
if (float.TryParse(str, out result))
65-
return float.Parse(str);
66-
67-
return defaultValue;
68-
}
69-
70-
/// <summary>
71-
/// Parse `str` to boolean, return `defaultValue` if failed.
72-
/// </summary>
73-
public static bool Parse(string str, bool defaultValue)
74-
{
75-
bool result;
76-
77-
if (bool.TryParse(str, out result))
78-
return bool.Parse(str);
79-
80-
return defaultValue;
81-
}
82-
83-
#endregion
84-
8531
#region Number
8632

8733
/// <summary>
@@ -503,6 +449,60 @@ public static List<T> RemoveEmptySlotIncludeMissing<T>(List<T> inList)
503449

504450
#endregion
505451

452+
#region Parse
453+
454+
/// <summary>
455+
/// Is the string the valid number to parse.
456+
/// </summary>
457+
/// <param name="str"></param>
458+
/// <returns></returns>
459+
public static bool IsNumberString(string str)
460+
{
461+
double test;
462+
return (double.TryParse(str, out test));
463+
}
464+
465+
/// <summary>
466+
/// Parse `str` to integer, return `defaultValue` if failed.
467+
/// </summary>
468+
public static int Parse(string str, int defaultValue)
469+
{
470+
int result;
471+
472+
if (int.TryParse(str, out result))
473+
return int.Parse(str);
474+
475+
return defaultValue;
476+
}
477+
478+
/// <summary>
479+
/// Parse `str` to float, return `defaultValue` if failed.
480+
/// </summary>
481+
public static float Parse(string str, float defaultValue)
482+
{
483+
float result;
484+
485+
if (float.TryParse(str, out result))
486+
return float.Parse(str);
487+
488+
return defaultValue;
489+
}
490+
491+
/// <summary>
492+
/// Parse `str` to boolean, return `defaultValue` if failed.
493+
/// </summary>
494+
public static bool Parse(string str, bool defaultValue)
495+
{
496+
bool result;
497+
498+
if (bool.TryParse(str, out result))
499+
return bool.Parse(str);
500+
501+
return defaultValue;
502+
}
503+
504+
#endregion
505+
506506
#region JSON
507507

508508
/// <summary>

docs/ScriptReference/Util/JCS_Util.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ 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. |
9+
| Delta | Delta the `num` with `val` and clamp the result with `min` and `max`. |
10+
| DeltaP | Delta the `num` with `val` by percentage and clamp the result with `min` and `max`. |
11+
| BytesToString | Convert byte array to string by charset type. |
12+
| StringToBytes | Convert string to byte array by charset type. |
13+
| EscapeURL | Simple version of escape url. |
1314
| GetValues | Get the value for each enum, use to loop through the enum. |
1415
| EnumSize | Returns the length of an enumerator. |
1516
| WithInRange | Check if the value is within the range. |
@@ -25,9 +26,10 @@ All code utility is stored here.
2526
| FillSlot | Fill slots with initialize value type by length. |
2627
| RemoveEmptySlot | Remove the null value from a list/array. |
2728
| RemoveEmptySlotIncludeMissing | Remove all the null value including missing reference in the list/array. |
28-
| BytesToString | Convert byte array to string by charset type. |
29-
| StringToBytes | Convert string to byte array by charset type. |
30-
| EscapeURL | Simple version of escape url. |
29+
| IsNumberString | Check if the string is a number string. |
30+
| Parse | Parse `str` to integer, return `defaultValue` if failed. |
31+
| Parse | Parse `str` to float, return `defaultValue` if failed. |
32+
| Parse | Parse `str` to boolean, return `defaultValue` if failed. |
3133
| ToJson | Serialize object to JSON string. |
3234
| EnableComponent | Do enable/distance component. |
3335
| ForceGetComponent | Force to get a component, if not found add one new then. |

0 commit comments

Comments
 (0)