File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Assets/JCSUnity/Scripts/Util Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 66 * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright (c) 2017 by Shen, Jen-Chieh $
88 */
9+ using System . Collections . Generic ;
910using UnityEngine ;
1011
1112namespace JCSUnity
@@ -77,5 +78,22 @@ private static float FindDecimalInclude(float num)
7778
7879 return 1.0f / Mathf . Pow ( 10.0f , str . Length ) ;
7980 }
81+
82+ /// <summary>
83+ /// Choose one object from the list.
84+ /// </summary>
85+ /// <typeparam name="T"> Type of the object. </typeparam>
86+ /// <param name="inArray"> The list or array to choose from. </param>
87+ /// <returns> The chosen object from the list or array. </returns>
88+ public static T ChooseOne < T > ( T [ ] inArray )
89+ {
90+ int index = Range ( 0 , inArray . Length ) ;
91+ return inArray [ index ] ;
92+ }
93+ public static T ChooseOne < T > ( List < T > inList )
94+ {
95+ int index = Range ( 0 , inList . Count ) ;
96+ return inList [ index ] ;
97+ }
8098 }
8199}
You can’t perform that action at this time.
0 commit comments