@@ -111,7 +111,7 @@ public static int EnumSize<T>()
111111
112112 #endregion
113113
114- #region Array
114+ #region List
115115
116116 /// <summary>
117117 /// Check the value within the range plus acceptable range.
@@ -341,6 +341,86 @@ public static T ListPopBack<T>(List<T> list)
341341 return data ;
342342 }
343343
344+ /// <summary>
345+ /// Fill slots with initialize value type by length.
346+ /// </summary>
347+ /// <typeparam name="T"> Type from `inArray`. </typeparam>
348+ /// <param name="inArray"> Array you would like to fill out. </param>
349+ /// <param name="len"> Target length to initialize. </param>
350+ /// <param name="with"> Initialize object type. </param>
351+ /// <returns> Return filled array. </returns>
352+ public static T [ ] FillSlot < T > ( T [ ] inArray , int len , T with )
353+ {
354+ return FillSlot ( inArray . ToList ( ) , len , with ) . ToArray ( ) ;
355+ }
356+
357+ public static List < T > FillSlot < T > ( List < T > inList , int len , T with )
358+ {
359+ for ( int index = inList . Count ; index < len ; ++ index )
360+ inList . Add ( with ) ;
361+ return inList ;
362+ }
363+
364+ /// <summary>
365+ /// Remove the empty slot in the array.
366+ /// </summary>
367+ /// <typeparam name="T"> Type of the List. </typeparam>
368+ /// <param name="inArray"> Array list. </param>
369+ /// <returns> Cleaned up Array object. </returns>
370+ public static T [ ] RemoveEmptySlot < T > ( T [ ] inArray )
371+ {
372+ return RemoveEmptySlot ( inArray . ToList ( ) ) . ToArray ( ) ;
373+ }
374+ public static List < T > RemoveEmptySlot < T > ( List < T > inList )
375+ {
376+ List < T > newArray = new List < T > ( inList . Count ) ;
377+
378+ for ( int index = 0 ; index < inList . Count ; ++ index )
379+ {
380+ // Add itself if exists.
381+ if ( inList [ index ] != null )
382+ newArray . Add ( inList [ index ] ) ;
383+ }
384+
385+ return newArray ;
386+ }
387+
388+ /// <summary>
389+ /// Remove the empty slot in the list including remove
390+ /// the missing gameobject too.
391+ ///
392+ /// I guess Unity do the CG collection later a while when
393+ /// you call 'Destory()' function. Before scripting layer
394+ /// acknowledge this game object is destory might be too
395+ /// late in some situation. This will avoid this type of
396+ /// issue/circumstance.
397+ /// </summary>
398+ /// <typeparam name="T"> Type of the List. </typeparam>
399+ /// <param name="inList"> List object. </param>
400+ /// <returns> Cleaned up List object. </returns>
401+ public static T [ ] RemoveEmptySlotIncludeMissing < T > ( T [ ] inArray )
402+ where T : UnityEngine . Object
403+ {
404+ return RemoveEmptySlotIncludeMissing ( inArray . ToList ( ) ) . ToArray ( ) ;
405+ }
406+ public static List < T > RemoveEmptySlotIncludeMissing < T > ( List < T > inList )
407+ where T : UnityEngine . Object
408+ {
409+ List < T > newArray = new List < T > ( inList . Count ) ;
410+
411+ for ( int index = 0 ; index < inList . Count ; ++ index )
412+ {
413+ // Add itself if exists.
414+ //
415+ // SOURCE(jenchieh): https://answers.unity.com/questions/131158/how-can-i-check-if-an-object-is-null.html
416+ // INFORMATION(jenchieh): https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
417+ if ( inList [ index ] ?? false )
418+ newArray . Add ( inList [ index ] ) ;
419+ }
420+
421+ return newArray ;
422+ }
423+
344424 #endregion
345425
346426 #region String
@@ -1086,90 +1166,6 @@ public static TweenDelegate GetEasing(JCS_TweenType type)
10861166
10871167 #endregion
10881168
1089- #region List
1090-
1091- /// <summary>
1092- /// Fill slots with initialize value type by length.
1093- /// </summary>
1094- /// <typeparam name="T"> Type from `inArray`. </typeparam>
1095- /// <param name="inArray"> Array you would like to fill out. </param>
1096- /// <param name="len"> Target length to initialize. </param>
1097- /// <param name="with"> Initialize object type. </param>
1098- /// <returns> Return filled array. </returns>
1099- public static T [ ] FillSlot < T > ( T [ ] inArray , int len , T with )
1100- {
1101- return FillSlot ( inArray . ToList ( ) , len , with ) . ToArray ( ) ;
1102- }
1103-
1104- public static List < T > FillSlot < T > ( List < T > inList , int len , T with )
1105- {
1106- for ( int index = inList . Count ; index < len ; ++ index )
1107- inList . Add ( with ) ;
1108- return inList ;
1109- }
1110-
1111- /// <summary>
1112- /// Remove the empty slot in the array.
1113- /// </summary>
1114- /// <typeparam name="T"> Type of the List. </typeparam>
1115- /// <param name="inArray"> Array list. </param>
1116- /// <returns> Cleaned up Array object. </returns>
1117- public static T [ ] RemoveEmptySlot < T > ( T [ ] inArray )
1118- {
1119- return RemoveEmptySlot ( inArray . ToList ( ) ) . ToArray ( ) ;
1120- }
1121- public static List < T > RemoveEmptySlot < T > ( List < T > inList )
1122- {
1123- List < T > newArray = new List < T > ( inList . Count ) ;
1124-
1125- for ( int index = 0 ; index < inList . Count ; ++ index )
1126- {
1127- // Add itself if exists.
1128- if ( inList [ index ] != null )
1129- newArray . Add ( inList [ index ] ) ;
1130- }
1131-
1132- return newArray ;
1133- }
1134-
1135- /// <summary>
1136- /// Remove the empty slot in the list including remove
1137- /// the missing gameobject too.
1138- ///
1139- /// I guess Unity do the CG collection later a while when
1140- /// you call 'Destory()' function. Before scripting layer
1141- /// acknowledge this game object is destory might be too
1142- /// late in some situation. This will avoid this type of
1143- /// issue/circumstance.
1144- /// </summary>
1145- /// <typeparam name="T"> Type of the List. </typeparam>
1146- /// <param name="inList"> List object. </param>
1147- /// <returns> Cleaned up List object. </returns>
1148- public static T [ ] RemoveEmptySlotIncludeMissing < T > ( T [ ] inArray )
1149- where T : UnityEngine . Object
1150- {
1151- return RemoveEmptySlotIncludeMissing ( inArray . ToList ( ) ) . ToArray ( ) ;
1152- }
1153- public static List < T > RemoveEmptySlotIncludeMissing < T > ( List < T > inList )
1154- where T : UnityEngine . Object
1155- {
1156- List < T > newArray = new List < T > ( inList . Count ) ;
1157-
1158- for ( int index = 0 ; index < inList . Count ; ++ index )
1159- {
1160- // Add itself if exists.
1161- //
1162- // SOURCE(jenchieh): https://answers.unity.com/questions/131158/how-can-i-check-if-an-object-is-null.html
1163- // INFORMATION(jenchieh): https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
1164- if ( inList [ index ] ?? false )
1165- newArray . Add ( inList [ index ] ) ;
1166- }
1167-
1168- return newArray ;
1169- }
1170-
1171- #endregion
1172-
11731169 #region Scene
11741170
11751171 /// <summary>
@@ -1212,7 +1208,7 @@ public static bool IsSceneExists(string name)
12121208 #region Animation
12131209
12141210 /// <summary>
1215- /// Sets the weight of the layer at the given index .
1211+ /// Sets the weight of the layer at the given name .
12161212 ///
12171213 /// Similar to `Animationr.SetLayerWeight` but accept string name.
12181214 /// </summary>
@@ -1229,7 +1225,7 @@ public static void SetLayerWeight(Animator ator, int index, float val)
12291225 }
12301226
12311227 /// <summary>
1232- /// Sets the weight of the layer at the given index .
1228+ /// Returns the weight of the layer at the specified name .
12331229 ///
12341230 /// Similar to `Animationr.SetLayerWeight` but accept string name.
12351231 /// </summary>
0 commit comments