Elin Decompiled Documentation EA 23.357 Nightly
Loading...
Searching...
No Matches
ClassExtension.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Reflection;
7using System.Text;
8using System.Text.RegularExpressions;
9using Pluralize.NET;
10using Unity.Collections.LowLevel.Unsafe;
11using UnityEngine;
12using UnityEngine.Events;
13using UnityEngine.UI;
14
15public static class ClassExtension
16{
17 public static class EnumSize<T>
18 {
19 public static readonly bool IsInt = typeof(T).IsEnum && Enum.GetUnderlyingType(typeof(T)) == typeof(int);
20
21 public static readonly bool IsLong = typeof(T).IsEnum && Enum.GetUnderlyingType(typeof(T)) == typeof(long);
22 }
23
24 public static class EnumNames<T>
25 {
26 public static readonly Dictionary<string, T> cached;
27
28 public static readonly Dictionary<string, T> fuzzy;
29
30 static EnumNames()
31 {
32 cached = new Dictionary<string, T>();
33 fuzzy = new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase);
34 string[] names = Enum.GetNames(typeof(T));
35 foreach (string text in names)
36 {
37 T value = (T)Enum.Parse(typeof(T), text);
38 cached[text] = value;
39 fuzzy.TryAdd(text, value);
40 }
41 }
42 }
43
44 private static Vector3 vector3;
45
46 public static IPluralize pluralizer = new Pluralizer();
47
48 public static string lang(this string s)
49 {
50 return Lang.Get(s);
51 }
52
53 public static string langPlural(this string s, int i)
54 {
55 string text = Lang.Get(s);
56 return Lang.Parse((i <= 1 || !Lang.setting.pluralize) ? text : pluralizer.Pluralize(text), i.ToString() ?? "");
57 }
58
59 public static string lang(this string s, string ref1, string ref2 = null, string ref3 = null, string ref4 = null, string ref5 = null)
60 {
61 return Lang.Parse(s, ref1, ref2, ref3, ref4, ref5);
62 }
63
64 public static string[] langList(this string s)
65 {
66 return Lang.GetList(s);
67 }
68
69 public static string langGame(this string s)
70 {
71 return Lang.Game.Get(s);
72 }
73
74 public static string langGame(this string s, string ref1, string ref2 = null, string ref3 = null, string ref4 = null)
75 {
76 return Lang.Game.Parse(s, ref1, ref2, ref3, ref4);
77 }
78
79 public static string Parentheses(this string str)
80 {
81 return "(" + str + ")";
82 }
83
84 public static string Bracket(this string str, int type = 0)
85 {
86 switch (type)
87 {
88 case -1:
89 return str;
90 case 1:
91 case 2:
92 case 3:
93 case 4:
94 case 5:
95 {
96 string[] list = Lang.GetList("bracket_" + type);
97 return list[0] + str + list[1];
98 }
99 default:
100 return "_bracketLeft".lang() + str + "_bracketRight".lang();
101 }
102 }
103
104 public static byte[] ToBytes(this BitArray bits)
105 {
106 byte[] array = new byte[(bits.Length - 1) / 8 + 1];
107 bits.CopyTo(array, 0);
108 return array;
109 }
110
111 public static bool GetBit(this byte pByte, int bitNo)
112 {
113 return (pByte & (1 << bitNo)) != 0;
114 }
115
116 public static byte SetBit(this byte pByte, int bitNo, bool value)
117 {
118 if (!value)
119 {
120 return Convert.ToByte(pByte & ~(1 << bitNo));
121 }
122 return Convert.ToByte(pByte | (1 << bitNo));
123 }
124
125 public static int ToInt3(this float a)
126 {
127 return (int)(a * 1000f);
128 }
129
130 public static float FromInt3(this int a)
131 {
132 return (float)a / 1000f;
133 }
134
135 public static int ToInt2(this float a)
136 {
137 return (int)(a * 100f);
138 }
139
140 public static float FromInt2(this int a)
141 {
142 return (float)a / 100f;
143 }
144
145 public static int Minimum(this int i)
146 {
147 if (i != 0)
148 {
149 if (i <= 0)
150 {
151 return -1;
152 }
153 return 1;
154 }
155 return 0;
156 }
157
158 public static bool IsNull(this object o)
159 {
160 return o == null;
161 }
162
163 public static bool IsOn(this int data, int digit)
164 {
165 BitArray32 bitArray = default(BitArray32);
166 bitArray.SetInt(data);
167 return bitArray[digit];
168 }
169
170 public static T ToEnum<T>(this int value)
171 {
172 if (!EnumSize<T>.IsInt)
173 {
174 return (T)Enum.ToObject(typeof(T), value);
175 }
176 return UnsafeUtility.As<int, T>(ref value);
177 }
178
179 public static T ToEnum<T>(this long value)
180 {
181 if (!EnumSize<T>.IsLong)
182 {
183 return (T)Enum.ToObject(typeof(T), value);
184 }
185 return UnsafeUtility.As<long, T>(ref value);
186 }
187
188 public static T ToEnum<T>(this string value, bool ignoreCase = true)
189 {
190 if (EnumNames<T>.cached.TryGetValue(value, out var value2))
191 {
192 return value2;
193 }
194 if (ignoreCase && EnumNames<T>.fuzzy.TryGetValue(value, out value2))
195 {
196 return value2;
197 }
198 return (T)Enum.Parse(typeof(T), value, ignoreCase);
199 }
200
201 public static Type ToType(this string value)
202 {
203 return Type.GetType("Elona." + value + ", Assembly-CSharp");
204 }
205
206 public static T NextEnum<T>(this T src) where T : struct
207 {
208 return ((T[])Enum.GetValues(src.GetType())).NextItem(src);
209 }
210
211 public static T PrevEnum<T>(this T src) where T : struct
212 {
213 return ((T[])Enum.GetValues(src.GetType())).PrevItem(src);
214 }
215
216 public static bool Within(this int v, int v2, int range)
217 {
218 if (v - v2 >= range)
219 {
220 return v - v2 < -range;
221 }
222 return true;
223 }
224
225 public static bool Within(this byte v, byte v2, byte range)
226 {
227 if (v - v2 >= range)
228 {
229 return v - v2 < -range;
230 }
231 return true;
232 }
233
234 public static int Clamp(this int v, int min, int max, bool loop = false)
235 {
236 if (v < min)
237 {
238 v = ((!loop) ? min : max);
239 }
240 else if (v > max)
241 {
242 v = ((!loop) ? max : min);
243 }
244 return v;
245 }
246
247 public static int ClampMin(this int v, int min)
248 {
249 if (v >= min)
250 {
251 return v;
252 }
253 return min;
254 }
255
256 public static int ClampMax(this int v, int max)
257 {
258 if (v <= max)
259 {
260 return v;
261 }
262 return max;
263 }
264
265 public static T ToField<T>(this string s, object o)
266 {
267 return (T)o.GetType().GetField(s).GetValue(o);
268 }
269
270 public static bool HasField<T>(this object o, string name)
271 {
272 FieldInfo field = o.GetType().GetField(name);
273 if (field != null)
274 {
275 return typeof(T).IsAssignableFrom(field.FieldType);
276 }
277 return false;
278 }
279
280 public static T GetField<T>(this object o, string name)
281 {
282 return (T)o.GetType().GetField(name).GetValue(o);
283 }
284
285 public static void SetField<T>(this object o, string name, T value)
286 {
287 o.GetType().GetField(name).SetValue(o, value);
288 }
289
290 public static T GetProperty<T>(this object o, string name)
291 {
292 return (T)o.GetType().GetProperty(name).GetValue(o);
293 }
294
295 public static void SetProperty<T>(this object o, string name, T value)
296 {
297 o.GetType().GetProperty(name).SetValue(o, value);
298 }
299
300 public static void Sort<T>(this IList<T> list, Comparison<T> comparison)
301 {
302 if (list is List<T>)
303 {
304 ((List<T>)list).Sort(comparison);
305 return;
306 }
307 List<T> list2 = new List<T>(list);
308 list2.Sort(comparison);
309 for (int i = 0; i < list.Count; i++)
310 {
311 list[i] = list2[i];
312 }
313 }
314
315 public static void Sort<T>(this IList<T> list, Func<T, int> keySelector)
316 {
317 List<T> list2 = list.OrderBy(keySelector).ToList();
318 list.Clear();
319 foreach (T item in list2)
320 {
321 list.Add(item);
322 }
323 }
324
325 public static TValue TryGet<TValue>(this IList<TValue> array, int index, int defIndex = -1)
326 {
327 if (array.Count != 0)
328 {
329 if (index >= array.Count)
330 {
331 if (defIndex != -1)
332 {
333 if (array.Count <= defIndex)
334 {
335 return array[Mathf.Max(0, array.Count - 1)];
336 }
337 return array[defIndex];
338 }
339 return array[Mathf.Max(0, array.Count - 1)];
340 }
341 return array[Math.Max(0, index)];
342 }
343 return default(TValue);
344 }
345
346 public static TValue TryGet<TValue>(this IList<TValue> array, int index, bool returnNull)
347 {
348 if (index >= array.Count)
349 {
350 return default(TValue);
351 }
352 return array[index];
353 }
354
355 public static bool IsEmpty(this Array array)
356 {
357 if (array != null)
358 {
359 return array.Length == 0;
360 }
361 return true;
362 }
363
364 public static int IndexOf(this IList<Component> list, GameObject go)
365 {
366 if (!go)
367 {
368 return -1;
369 }
370 for (int i = 0; i < list.Count; i++)
371 {
372 if (list[i].gameObject == go)
373 {
374 return i;
375 }
376 }
377 return -1;
378 }
379
380 public static TValue Move<TValue>(this IList<TValue> list, TValue target, int a)
381 {
382 int num = list.IndexOf(target);
383 int num2 = num + a;
384 if (num2 < 0)
385 {
386 num2 = list.Count - 1;
387 }
388 if (num2 >= list.Count)
389 {
390 num2 = 0;
391 }
392 list.Remove(target);
393 list.Insert(num2, target);
394 return list[num];
395 }
396
397 public static IList<TValue> Copy<TValue>(this IList<TValue> list)
398 {
399 return list.ToList();
400 }
401
402 public static void Each<TValue>(this IList<TValue> list, Action<TValue> action)
403 {
404 for (int num = list.Count - 1; num >= 0; num--)
405 {
406 action(list[num]);
407 }
408 }
409
410 public static IList<TValue> Shuffle<TValue>(this IList<TValue> list)
411 {
412 int num = list.Count;
413 while (num > 1)
414 {
415 int index = Rand._random.Next(num);
416 num--;
417 TValue value = list[num];
418 list[num] = list[index];
419 list[index] = value;
420 }
421 return list;
422 }
423
424 public static TValue TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key, TValue fallback = default(TValue))
425 {
426 TValue value = default(TValue);
427 if (key != null && source.TryGetValue(key, out value))
428 {
429 return value;
430 }
431 return fallback;
432 }
433
434 public static TValue TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key, TKey key_fallback)
435 {
436 TValue value = default(TValue);
437 if (key != null && source.TryGetValue(key, out value))
438 {
439 return value;
440 }
441 return source[key_fallback];
442 }
443
444 public static TValue GetOrCreate<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, Func<TValue> func = null)
445 {
446 TValue val = dict.TryGetValue(key);
447 if (val == null)
448 {
449 val = ((func != null) ? func() : Activator.CreateInstance<TValue>());
450 dict.Add(key, val);
451 }
452 return val;
453 }
454
455 public static TKey[] CopyKeys<TKey, TValue>(this IDictionary<TKey, TValue> dict)
456 {
457 TKey[] array = new TKey[dict.Keys.Count];
458 dict.Keys.CopyTo(array, 0);
459 return array;
460 }
461
462 public static TValue[] CopyValues<TKey, TValue>(this IDictionary<TKey, TValue> dict)
463 {
464 TValue[] array = new TValue[dict.Keys.Count];
465 dict.Values.CopyTo(array, 0);
466 return array;
467 }
468
469 public static T RandomItem<T>(this IEnumerable<T> ie)
470 {
471 int num = ie.Count();
472 if (num == 0)
473 {
474 return default(T);
475 }
476 return ie.ElementAt(Rand.rnd(num));
477 }
478
479 public static TValue RandomItem<TKey, TValue>(this IDictionary<TKey, TValue> source)
480 {
481 if (source.Count != 0)
482 {
483 return source.ElementAt(Rand.rnd(source.Count)).Value;
484 }
485 return default(TValue);
486 }
487
488 public static TValue RandomItem<TValue>(this IList<TValue> source)
489 {
490 if (source.Count != 0)
491 {
492 return source[Rand.rnd(source.Count)];
493 }
494 return default(TValue);
495 }
496
497 public static TValue RandomItem<TValue>(this IList<TValue> source, TValue exclude)
498 {
499 return source.RandomItem(source.IndexOf(exclude));
500 }
501
502 public static TValue RandomItem<TValue>(this IList<TValue> source, int exclude)
503 {
504 if (source.Count > 1)
505 {
506 int num;
507 do
508 {
509 num = Rand.rnd(source.Count);
510 }
511 while (num == exclude);
512 return source[num];
513 }
514 if (source.Count == 1)
515 {
516 return source[0];
517 }
518 return default(TValue);
519 }
520
521 public static TValue RandomItem<TValue>(this IList<TValue> source, Func<TValue, bool> funcValid, TValue defaultValue = default(TValue))
522 {
523 for (int i = 0; i < 100; i++)
524 {
525 TValue val = source[Rand.rnd(source.Count)];
526 if (funcValid(val))
527 {
528 return val;
529 }
530 }
531 return defaultValue;
532 }
533
534 public static TValue RandomItemWeighted<TValue>(this IList<TValue> source, Func<TValue, float> getWeight)
535 {
536 if (source.Count == 0)
537 {
538 return default(TValue);
539 }
540 if (source.Count == 1)
541 {
542 return source[0];
543 }
544 float num = 0f;
545 foreach (TValue item in source)
546 {
547 num += getWeight(item);
548 }
549 float num2 = Rand.Range(0f, num);
550 num = 0f;
551 foreach (TValue item2 in source)
552 {
553 num += getWeight(item2);
554 if (num2 < num)
555 {
556 return item2;
557 }
558 }
559 return source.First();
560 }
561
562 public static TValue Remainder<TValue>(this IList<TValue> source, int divider)
563 {
564 if (source.Count != 0)
565 {
566 return source[divider % source.Count];
567 }
568 return default(TValue);
569 }
570
571 public static TValue FirstItem<TKey, TValue>(this IDictionary<TKey, TValue> source)
572 {
573 if (source == null)
574 {
575 return default(TValue);
576 }
577 return source[source.First().Key];
578 }
579
580 public static TValue LastItem<TValue>(this IList<TValue> source)
581 {
582 if (source.Count != 0)
583 {
584 return source[source.Count - 1];
585 }
586 return default(TValue);
587 }
588
589 public static TValue NextItem<TValue>(this IList<TValue> source, ref int index)
590 {
591 index++;
592 if (index >= source.Count)
593 {
594 index = 0;
595 }
596 if (source.Count != 0)
597 {
598 return source[index];
599 }
600 return default(TValue);
601 }
602
603 public static int NextIndex<TValue>(this IList<TValue> source, TValue val)
604 {
605 if (val == null)
606 {
607 return 0;
608 }
609 int num = source.IndexOf(val) + 1;
610 if (num >= source.Count)
611 {
612 num = 0;
613 }
614 return num;
615 }
616
617 public static TValue NextItem<TValue>(this IList<TValue> source, TValue val)
618 {
619 int num = source.IndexOf(val) + 1;
620 if (num >= source.Count)
621 {
622 num = 0;
623 }
624 if (source.Count != 0)
625 {
626 return source[num];
627 }
628 return default(TValue);
629 }
630
631 public static TValue PrevItem<TValue>(this IList<TValue> source, TValue val)
632 {
633 int num = source.IndexOf(val) - 1;
634 if (num < 0)
635 {
636 num = source.Count - 1;
637 }
638 if (source.Count != 0)
639 {
640 return source[num];
641 }
642 return default(TValue);
643 }
644
645 public static TValue Clamp<TValue>(this IList<TValue> source, int i)
646 {
647 if (i < 0)
648 {
649 i = 0;
650 }
651 else if (i >= source.Count)
652 {
653 i = source.Count - 1;
654 }
655 return source[i];
656 }
657
658 public static List<T> GetList<T>(this IDictionary source)
659 {
660 List<T> list = new List<T>();
661 foreach (object value in source.Values)
662 {
663 if (value is T)
664 {
665 list.Add((T)value);
666 }
667 }
668 return list;
669 }
670
671 public static void ToDictionary<T>(this IList<UPair<T>> list, ref Dictionary<string, T> dic)
672 {
673 dic = new Dictionary<string, T>();
674 for (int i = 0; i < list.Count; i++)
675 {
676 dic.Add(list[i].name, list[i].value);
677 }
678 }
679
680 public static T FindMax<T>(this List<T> list, Func<T, int> func)
681 {
682 int num = int.MinValue;
683 T result = default(T);
684 foreach (T item in list)
685 {
686 int num2 = func(item);
687 if (num2 > num)
688 {
689 num = num2;
690 result = item;
691 }
692 }
693 return result;
694 }
695
696 public static void Set<T1, T2>(this Dictionary<T1, T2> dic, Dictionary<T1, T2> from)
697 {
698 dic.Clear();
699 foreach (KeyValuePair<T1, T2> item in from)
700 {
701 dic[item.Key] = item.Value;
702 }
703 }
704
705 public static string[] SplitByNewline(this string text)
706 {
707 if (string.IsNullOrEmpty(text))
708 {
709 return new string[0];
710 }
711 return text.Split(new string[3] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
712 }
713
714 public static string RemoveNewline(this string text)
715 {
716 if (string.IsNullOrEmpty(text))
717 {
718 return text;
719 }
720 return text.Replace("\r", "").Replace("\n", "");
721 }
722
723 public static string RemoveAllTags(this string text)
724 {
725 if (string.IsNullOrEmpty(text))
726 {
727 return text;
728 }
729 return Regex.Replace(text, "<.*?>", "");
730 }
731
732 public static int Calc(this string str, int power = 0, int ele = 0, int p2 = 0)
733 {
734 return Cal.Calcuate(str.Replace("p2", p2.ToString() ?? "").Replace("p", power.ToString() ?? "").Replace("e", ele.ToString() ?? "")
735 .Replace(";", ","));
736 }
737
738 public static int ToInt<T>(this string str)
739 {
740 return str.ToInt(typeof(T));
741 }
742
743 public static int ToInt(this string str, Type type)
744 {
745 FieldInfo field = type.GetField(str, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
746 if (field == null)
747 {
748 Debug.LogError("Field is null:" + str + "/" + type);
749 return -1;
750 }
751 return (int)field.GetValue(null);
752 }
753
754 public static int ToInt(this string str)
755 {
756 if (int.TryParse(str, out var result))
757 {
758 return result;
759 }
760 return 0;
761 }
762
763 public static long ToLong(this string str)
764 {
765 if (long.TryParse(str, out var result))
766 {
767 return result;
768 }
769 return 0L;
770 }
771
772 public static float ToFloat(this string str)
773 {
774 float result = 0f;
775 try
776 {
777 if (!float.TryParse(str, out result))
778 {
779 Debug.Log("exception: ToFlat1" + str);
780 result = 1f;
781 }
782 }
783 catch
784 {
785 Debug.Log("exception: ToFlat2" + str);
786 result = 1f;
787 }
788 return result;
789 }
790
791 public static string StripLastPun(this string str)
792 {
793 if (str != null)
794 {
795 return str.TrimEnd(Lang.words.period);
796 }
797 return str;
798 }
799
800 public static string StripPun(this string str, bool stripComma, bool insertSpaceForComma = false)
801 {
802 StringBuilder stringBuilder = new StringBuilder();
803 foreach (char c in str)
804 {
805 if (c == Lang.words.comma)
806 {
807 if (stripComma)
808 {
809 if (insertSpaceForComma)
810 {
811 stringBuilder.Append('\u3000');
812 }
813 }
814 else
815 {
816 stringBuilder.Append(c);
817 }
818 }
819 else if (c != Lang.words.period)
820 {
821 stringBuilder.Append(c);
822 }
823 }
824 return stringBuilder.ToString();
825 }
826
827 public static string Repeat(this string str, int count)
828 {
829 StringBuilder stringBuilder = new StringBuilder();
830 for (int i = 0; i < Mathf.Abs(count); i++)
831 {
832 stringBuilder.Append(str);
833 }
834 return stringBuilder.ToString();
835 }
836
837 public static string StripBrackets(this string str)
838 {
839 HashSet<char> brackets = new HashSet<char> { '"', '「', '」', '“', '”' };
840 return string.Concat(str.Where((char c) => !brackets.Contains(c)));
841 }
842
843 public static string TryAddExtension(this string s, string ext)
844 {
845 if (!s.Contains("." + ext))
846 {
847 return s + "." + ext;
848 }
849 return s;
850 }
851
852 public static bool IsEmpty(this string str)
853 {
854 if (str != null)
855 {
856 return str == "";
857 }
858 return true;
859 }
860
861 public static string IsEmpty(this string str, string defaultStr)
862 {
863 if (str != null && !(str == ""))
864 {
865 return str;
866 }
867 return defaultStr;
868 }
869
870 public static string TrimNewLines(this string text)
871 {
872 while (text.EndsWith(Environment.NewLine))
873 {
874 text = text.Substring(0, text.Length - Environment.NewLine.Length);
875 }
876 return text;
877 }
878
879 public static int[] SplitToInts(this string str, char separator)
880 {
881 string[] array = str.Split(separator);
882 int[] array2 = new int[array.Length];
883 for (int i = 0; i < array.Length; i++)
884 {
885 array2[i] = int.Parse(array[i]);
886 }
887 return array2;
888 }
889
890 public static string[] SplitNewline(this string str)
891 {
892 return str.Split(Environment.NewLine.ToCharArray());
893 }
894
895 public static bool Contains(this string[] strs, string id)
896 {
897 if (strs == null || strs.Length == 0)
898 {
899 return false;
900 }
901 for (int i = 0; i < strs.Length; i++)
902 {
903 if (strs[i] == id)
904 {
905 return true;
906 }
907 }
908 return false;
909 }
910
911 public static string Evalute(this string[] array, float val)
912 {
913 return array[(int)Mathf.Clamp((float)(array.Length - 1) * val, 0f, array.Length - 1)];
914 }
915
916 public static string ToShortNumber(this int a)
917 {
918 if (a < 0)
919 {
920 string text;
921 if (a > -1000000)
922 {
923 if (a <= -1000)
924 {
925 return a / 1000 + "K";
926 }
927 text = a.ToString();
928 if (text == null)
929 {
930 return "";
931 }
932 }
933 else
934 {
935 text = a / 1000000 + "M";
936 }
937 return text;
938 }
939 string text2;
940 if (a < 1000000)
941 {
942 if (a >= 1000)
943 {
944 return a / 1000 + "K";
945 }
946 text2 = a.ToString();
947 if (text2 == null)
948 {
949 return "";
950 }
951 }
952 else
953 {
954 text2 = a / 1000000 + "M";
955 }
956 return text2;
957 }
958
959 public static string ToFormat(this int a)
960 {
961 return $"{a:#,0}";
962 }
963
964 public static string ToFormat(this long a)
965 {
966 return $"{a:#,0}";
967 }
968
969 public static string ToText(this int a, bool skipIfZero = true)
970 {
971 object obj;
972 if (!(a == 0 && skipIfZero))
973 {
974 if (a >= 0)
975 {
976 return "+" + a;
977 }
978 obj = a.ToString();
979 if (obj == null)
980 {
981 return "";
982 }
983 }
984 else
985 {
986 obj = "";
987 }
988 return (string)obj;
989 }
990
991 public static string TagColor(this string s, Color c, string txt)
992 {
993 return s + "<color=" + c.ToHex() + ">" + txt + "</color>";
994 }
995
996 public static string TagColor(this string s, Color c)
997 {
998 return "<color=" + c.ToHex() + ">" + s + "</color>";
999 }
1000
1001 public static string TagSize(this string s, string txt, int size)
1002 {
1003 return s + "<size=" + size + ">" + txt + "</size>";
1004 }
1005
1006 public static string TagSize(this string s, int size)
1007 {
1008 return "<size=" + size + ">" + s + "</size>";
1009 }
1010
1011 public static bool HasTag(this string s, string id, char splitter = '/')
1012 {
1013 return s.Split(splitter).Contains(id);
1014 }
1015
1016 public static string SetTag(this string s, string id, bool enable, char splitter = '/')
1017 {
1018 s = ((!enable) ? s.RemoveTag(id, splitter) : s.AddTag(id, splitter));
1019 return s;
1020 }
1021
1022 public static string AddTag(this string s, string id, char splitter = '/')
1023 {
1024 if (!s.HasTag(id, splitter))
1025 {
1026 s = s + (s.IsEmpty() ? "" : ((object)splitter))?.ToString() + id;
1027 }
1028 return s;
1029 }
1030
1031 public static string RemoveTag(this string s, string id, char splitter = '/')
1032 {
1033 string[] array = s.Split(splitter);
1034 s = "";
1035 string[] array2 = array;
1036 foreach (string text in array2)
1037 {
1038 if (!(text == id))
1039 {
1040 s.AddTag(text, splitter);
1041 }
1042 }
1043 return s;
1044 }
1045
1046 public static string GetFullFileNameWithoutExtension(this FileInfo fileInfo)
1047 {
1048 return fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name);
1049 }
1050
1051 public static string GetFullFileNameWithoutExtension(this string path)
1052 {
1053 return new FileInfo(path).GetFullFileNameWithoutExtension();
1054 }
1055
1056 public static string Pluralize(string s)
1057 {
1058 if (s == "talisman")
1059 {
1060 return "talismans";
1061 }
1062 return pluralizer.Pluralize(s);
1063 }
1064
1065 public static string GetSpecialArticle(string a)
1066 {
1067 if (a.ToLower() == "unicorn")
1068 {
1069 return "a ";
1070 }
1071 return null;
1072 }
1073
1074 public static string AddArticle(this string s)
1075 {
1076 if (!Lang.setting.addArticle || s.Length < 1)
1077 {
1078 return s;
1079 }
1080 char c = s.ToLower()[0];
1081 s = (GetSpecialArticle(s) ?? ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ")) + s;
1082 return s;
1083 }
1084
1085 public static string AddArticle(this string s, int num, ArticleStyle style = ArticleStyle.Default, string replace = null)
1086 {
1087 if (!Lang.setting.addArticle || s.Length < 1)
1088 {
1089 return s;
1090 }
1091 char c = s[0];
1092 string text = ((num >= 2) ? (num.ToFormat() + " ") : (GetSpecialArticle(s) ?? ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ")));
1093 if (num >= 2 && Lang.setting.pluralize)
1094 {
1095 s = ((replace.IsEmpty() || !s.Contains(replace) || s.Contains("limestone stone")) ? Pluralize(s) : s.Replace(replace, Pluralize(replace)));
1096 }
1097 return style switch
1098 {
1099 ArticleStyle.The => "_the".lang().ToTitleCase() + " " + ((num > 1) ? (num + " ") : "") + s,
1100 ArticleStyle.None => ((num > 1) ? (num.ToFormat() + " ") : "") + s.ToTitleCase(),
1101 _ => text + s,
1102 };
1103 }
1104
1105 public static string ToTitleCase(this string s, bool wholeText = false)
1106 {
1107 if (!Lang.setting.capitalize)
1108 {
1109 return s;
1110 }
1111 char[] array = s.ToCharArray();
1112 bool flag = true;
1113 for (int i = 0; i < array.Length; i++)
1114 {
1115 if (flag)
1116 {
1117 array[i] = char.ToUpper(array[i]);
1118 flag = false;
1119 }
1120 if (!wholeText)
1121 {
1122 break;
1123 }
1124 if (array[i] == ' ')
1125 {
1126 flag = true;
1127 }
1128 }
1129 return new string(array);
1130 }
1131
1132 public static string ToSentenceCase(this string s)
1133 {
1134 char[] array = s.ToCharArray();
1135 bool flag = true;
1136 for (int i = 0; i < array.Length; i++)
1137 {
1138 char c = array[i];
1139 if (char.IsLetter(c))
1140 {
1141 if (flag)
1142 {
1143 array[i] = char.ToUpperInvariant(c);
1144 }
1145 flag = false;
1146 }
1147 else if (c == '.' || c == '!' || c == '?')
1148 {
1149 flag = true;
1150 }
1151 }
1152 return new string(array);
1153 }
1154
1155 public static void LoopTail<T>(this List<T> list, bool vertical = false) where T : Selectable
1156 {
1157 if (list.Count > 1)
1158 {
1159 Navigation navigation = list[0].navigation;
1160 Navigation navigation2 = list[list.Count - 1].navigation;
1161 if (vertical)
1162 {
1163 navigation.selectOnUp = list[list.Count - 1];
1164 navigation2.selectOnDown = list[0];
1165 }
1166 else
1167 {
1168 navigation.selectOnLeft = list[list.Count - 1];
1169 navigation2.selectOnRight = list[0];
1170 }
1171 list[0].navigation = navigation;
1172 list[list.Count - 1].navigation = navigation2;
1173 }
1174 }
1175
1176 public static void SetNavigation(this Component a, Component b, bool vertical = false)
1177 {
1178 if (!a || !b)
1179 {
1180 return;
1181 }
1182 Selectable component = a.GetComponent<Selectable>();
1183 Selectable component2 = b.GetComponent<Selectable>();
1184 if ((bool)component && (bool)component2)
1185 {
1186 Navigation navigation = component.navigation;
1187 Navigation navigation2 = component2.navigation;
1188 if (vertical)
1189 {
1190 navigation.selectOnUp = component2;
1191 navigation2.selectOnDown = component;
1192 }
1193 else
1194 {
1195 navigation.selectOnLeft = component2;
1196 navigation2.selectOnRight = component;
1197 }
1198 component.navigation = navigation;
1199 component2.navigation = navigation2;
1200 }
1201 }
1202
1203 public static void LoopSelectable(this List<Selectable> sels, bool vertical = true, bool horizonal = true, bool asGroup = true)
1204 {
1205 for (int i = 0; i < sels.Count; i++)
1206 {
1207 Selectable selectable = sels[i];
1208 Selectable selectable2 = sels[0];
1209 Navigation navigation = selectable.navigation;
1210 if (horizonal)
1211 {
1212 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1213 }
1214 if (asGroup)
1215 {
1216 for (int j = i + 1; j < sels.Count; j++)
1217 {
1218 if (sels[j].transform.position.y < selectable.transform.position.y)
1219 {
1220 selectable2 = sels[j];
1221 break;
1222 }
1223 }
1224 }
1225 else
1226 {
1227 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1228 }
1229 if (vertical)
1230 {
1231 navigation.selectOnDown = selectable2;
1232 }
1233 selectable.navigation = navigation;
1234 }
1235 for (int num = sels.Count - 1; num >= 0; num--)
1236 {
1237 Selectable selectable3 = sels[num];
1238 Selectable selectable4 = sels[sels.Count - 1];
1239 Navigation navigation2 = selectable3.navigation;
1240 if (horizonal)
1241 {
1242 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1243 }
1244 if (asGroup)
1245 {
1246 int num2 = sels.Count - 1;
1247 for (int num3 = num - 1; num3 >= 0; num3--)
1248 {
1249 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1250 {
1251 num2 = num3;
1252 break;
1253 }
1254 }
1255 int num4 = num2;
1256 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1257 {
1258 selectable4 = sels[num4];
1259 num4--;
1260 }
1261 }
1262 else
1263 {
1264 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1265 }
1266 if (vertical)
1267 {
1268 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1269 }
1270 navigation2.mode = Navigation.Mode.Explicit;
1271 selectable3.navigation = navigation2;
1272 }
1273 }
1274
1275 public static void LoopSelectable(this Transform l, bool vertical = true, bool horizonal = true, bool asGroup = true)
1276 {
1277 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1278 for (int num = list.Count - 1; num >= 0; num--)
1279 {
1280 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1281 {
1282 list.RemoveAt(num);
1283 }
1284 }
1285 list.LoopSelectable(vertical, horizonal, asGroup);
1286 }
1287
1288 public static Color ToColor(this string s)
1289 {
1290 Color color = Color.white;
1291 ColorUtility.TryParseHtmlString("#" + s, out color);
1292 return color;
1293 }
1294
1295 public static void SetAlpha(this Image c, float a)
1296 {
1297 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1298 }
1299
1300 public static void SetAlpha(this RawImage c, float a)
1301 {
1302 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1303 }
1304
1305 public static Color SetAlpha(this Color c, float a)
1306 {
1307 c.a = a;
1308 return c;
1309 }
1310
1311 public static Color Multiply(this Color c, float mtp, float add)
1312 {
1313 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1314 }
1315
1316 public static string Tag(this Color c)
1317 {
1318 return "<color=" + $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}" + ">";
1319 }
1320
1321 public static string ToHex(this Color c)
1322 {
1323 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1324 }
1325
1326 public static void SetOnClick(this Button b, Action action)
1327 {
1328 b.onClick.RemoveAllListeners();
1329 b.onClick.AddListener(delegate
1330 {
1331 action();
1332 });
1333 }
1334
1335 public static void SetListener(this Button.ButtonClickedEvent e, Action action)
1336 {
1337 e.RemoveAllListeners();
1338 e.AddListener(delegate
1339 {
1340 action();
1341 });
1342 }
1343
1344 public static void SetAlpha(this Text text, float aloha = 1f)
1345 {
1346 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1347 }
1348
1349 public static string Fit(this Text text, string s, string suffix = "")
1350 {
1351 TextGenerationSettings generationSettings = text.GetGenerationSettings(Vector2.zero);
1352 TextGenerator cachedTextGeneratorForLayout = text.cachedTextGeneratorForLayout;
1353 float num = text.rectTransform.rect.width * text.pixelsPerUnit;
1354 if (cachedTextGeneratorForLayout.GetPreferredWidth(s + suffix, generationSettings) <= num)
1355 {
1356 return s + suffix;
1357 }
1358 int num2 = s.Length;
1359 while (num2 > 1 && cachedTextGeneratorForLayout.GetPreferredWidth(s[..num2].TrimEnd() + ".." + suffix, generationSettings) > num)
1360 {
1361 num2--;
1362 }
1363 return s[..num2].TrimEnd() + ".." + suffix;
1364 }
1365
1366 public static void SetSlider(this Slider slider, float value, Func<float, string> action, bool notify)
1367 {
1368 slider.SetSlider(value, action, -1, -1, notify);
1369 }
1370
1371 public static void SetSlider(this Slider slider, float value, Func<float, string> action, int min = -1, int max = -1, bool notify = true)
1372 {
1373 slider.onValueChanged.RemoveAllListeners();
1374 slider.onValueChanged.AddListener(delegate(float a)
1375 {
1376 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1377 });
1378 if (min != -1)
1379 {
1380 slider.minValue = min;
1381 slider.maxValue = max;
1382 }
1383 if (notify)
1384 {
1385 slider.value = value;
1386 }
1387 else
1388 {
1389 slider.SetValueWithoutNotify(value);
1390 }
1391 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1392 }
1393
1394 public static T GetOrCreate<T>(this Component t) where T : Component
1395 {
1396 T val = t.gameObject.GetComponent<T>();
1397 if (!val)
1398 {
1399 val = t.gameObject.AddComponent<T>();
1400 }
1401 return val;
1402 }
1403
1404 public static RectTransform Rect(this Component c)
1405 {
1406 return c.transform as RectTransform;
1407 }
1408
1409 public static void CopyRect(this RectTransform r, RectTransform t)
1410 {
1411 r.pivot = t.pivot;
1412 r.sizeDelta = t.sizeDelta;
1413 r.anchorMin = t.anchorMin;
1414 r.anchorMax = t.anchorMax;
1415 r.anchoredPosition = t.anchoredPosition;
1416 }
1417
1418 public static void ToggleActive(this Component c)
1419 {
1420 c.SetActive(!c.gameObject.activeSelf);
1421 }
1422
1423 public static void SetActive(this Component c, bool enable)
1424 {
1425 if (c.gameObject.activeSelf != enable)
1426 {
1427 c.gameObject.SetActive(enable);
1428 }
1429 }
1430
1431 public static void SetActive(this Component c, bool enable, Action<bool> onChangeState)
1432 {
1433 if (c.gameObject.activeSelf != enable)
1434 {
1435 c.gameObject.SetActive(enable);
1436 onChangeState(enable);
1437 }
1438 }
1439
1440 public static Selectable GetSelectable(this GameObject go)
1441 {
1442 return go.GetComponentInChildren<Selectable>();
1443 }
1444
1445 public static void SetLayerRecursively(this GameObject obj, int layer)
1446 {
1447 obj.layer = layer;
1448 foreach (Transform item in obj.transform)
1449 {
1450 item.gameObject.SetLayerRecursively(layer);
1451 }
1452 }
1453
1454 public static bool IsInteractable(this GameObject obj)
1455 {
1456 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1457 if ((bool)selectable)
1458 {
1459 return selectable.interactable;
1460 }
1461 return false;
1462 }
1463
1464 public static bool IsChildOf(this GameObject c, GameObject root)
1465 {
1466 if (c.transform == root.transform)
1467 {
1468 return true;
1469 }
1470 if ((bool)c.transform.parent)
1471 {
1472 return c.transform.parent.gameObject.IsChildOf(root);
1473 }
1474 return false;
1475 }
1476
1477 public static bool IsPrefab(this Component c)
1478 {
1479 return c.gameObject.scene.name == null;
1480 }
1481
1482 public static T CreateMold<T>(this Component c, string name = null) where T : Component
1483 {
1484 T result = null;
1485 for (int i = 0; i < c.transform.childCount; i++)
1486 {
1487 T component = c.transform.GetChild(i).GetComponent<T>();
1488 if ((bool)component && (name.IsEmpty() || name == component.name))
1489 {
1490 component.gameObject.SetActive(value: false);
1491 result = component;
1492 break;
1493 }
1494 }
1495 c.DestroyChildren();
1496 return result;
1497 }
1498
1499 public static Transform Find(this Component c, string name = null)
1500 {
1501 return c.Find<Transform>(name);
1502 }
1503
1504 public static T Find<T>(this Component c, string name = null, bool recursive = false) where T : Component
1505 {
1506 if (recursive)
1507 {
1508 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1509 foreach (T val in componentsInChildren)
1510 {
1511 if (name == null || name == val.name)
1512 {
1513 return val;
1514 }
1515 }
1516 return null;
1517 }
1518 for (int j = 0; j < c.transform.childCount; j++)
1519 {
1520 T component = c.transform.GetChild(j).GetComponent<T>();
1521 if ((bool)component && (name == null || name == component.name))
1522 {
1523 return component;
1524 }
1525 }
1526 return null;
1527 }
1528
1529 public static GameObject FindTagInParents(this Component c, string tag, bool includeInactive = true)
1530 {
1531 Transform transform = c.transform;
1532 for (int i = 0; i < transform.childCount; i++)
1533 {
1534 Transform child = transform.GetChild(i);
1535 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1536 {
1537 return child.gameObject;
1538 }
1539 }
1540 if ((bool)transform.parent)
1541 {
1542 return transform.parent.FindTagInParents(tag, includeInactive);
1543 }
1544 return null;
1545 }
1546
1547 public static T GetComponentInChildrenExcludSelf<T>(this Transform c) where T : Component
1548 {
1549 for (int i = 0; i < c.childCount; i++)
1550 {
1551 T component = c.GetChild(i).GetComponent<T>();
1552 if ((bool)component)
1553 {
1554 return component;
1555 }
1556 }
1557 return null;
1558 }
1559
1560 public static List<T> GetComponentsInDirectChildren<T>(this Transform comp, bool includeInactive = true) where T : Component
1561 {
1562 List<T> list = new List<T>();
1563 Transform transform = comp.transform;
1564 for (int i = 0; i < transform.childCount; i++)
1565 {
1566 T component = transform.GetChild(i).GetComponent<T>();
1567 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1568 {
1569 list.Add(component);
1570 }
1571 }
1572 return list;
1573 }
1574
1575 public static List<T> GetComponentsInDirectChildren<T>(this Component comp, bool includeInactive = true) where T : Component
1576 {
1577 List<T> list = new List<T>();
1578 Transform transform = comp.transform;
1579 for (int i = 0; i < transform.childCount; i++)
1580 {
1581 T component = transform.GetChild(i).GetComponent<T>();
1582 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1583 {
1584 list.Add(component);
1585 }
1586 }
1587 return list;
1588 }
1589
1590 public static T GetComponentInDirectChildren<T>(this Component comp) where T : Component
1591 {
1592 Transform transform = comp.transform;
1593 for (int i = 0; i < transform.childCount; i++)
1594 {
1595 T component = transform.GetChild(i).GetComponent<T>();
1596 if ((bool)component)
1597 {
1598 return component;
1599 }
1600 }
1601 return null;
1602 }
1603
1604 public static void DestroyChildren(this Component component, bool destroyInactive = false, bool ignoreDestroy = true)
1605 {
1606 if (!component || !component.transform)
1607 {
1608 Debug.LogWarning("DestroyChlidren:" + component);
1609 return;
1610 }
1611 for (int num = component.transform.childCount - 1; num >= 0; num--)
1612 {
1613 GameObject gameObject = component.transform.GetChild(num).gameObject;
1614 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1615 {
1616 UnityEngine.Object.DestroyImmediate(gameObject);
1617 }
1618 }
1619 }
1620
1621 public static bool IsMouseOver(this RectTransform r, Camera cam)
1622 {
1623 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1624 }
1625
1626 public static void RebuildLayout(this Component c, bool recursive = false)
1627 {
1628 if (recursive)
1629 {
1630 foreach (Transform item in c.transform)
1631 {
1632 if (item is RectTransform)
1633 {
1634 item.RebuildLayout(recursive: true);
1635 }
1636 }
1637 }
1638 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1639 }
1640
1641 public static void RebuildLayoutTo<T>(this Component c) where T : Component
1642 {
1643 c.RebuildLayout();
1644 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1645 {
1646 c.transform.parent.RebuildLayoutTo<T>();
1647 }
1648 }
1649
1650 public static void RebuildLayoutTo(this Component c, Component target)
1651 {
1652 c.RebuildLayout();
1653 if (!(c == target) && (bool)c.transform.parent)
1654 {
1655 c.transform.parent.RebuildLayoutTo(target);
1656 }
1657 }
1658
1659 public static void SetRect(this RectTransform r, float x, float y, float w, float h, float pivotX, float pivotY, float minX, float minY, float maxX, float maxY)
1660 {
1661 r.SetPivot(pivotX, pivotY);
1662 r.SetAnchor(minX, minY, maxX, maxY);
1663 if (w != -1f)
1664 {
1665 r.sizeDelta = new Vector2(w, h);
1666 }
1667 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1668 }
1669
1670 public static void SetPivot(this RectTransform r, float x, float y)
1671 {
1672 r.pivot = new Vector2(x, y);
1673 }
1674
1675 public static void SetAnchor(this RectTransform r, float minX, float minY, float maxX, float maxY)
1676 {
1677 r.anchorMin = new Vector2(minX, minY);
1678 r.anchorMax = new Vector2(maxX, maxY);
1679 }
1680
1681 public static void _SetAnchor(this RectTransform _rect, RectPosition anchor)
1682 {
1683 switch (anchor)
1684 {
1685 case RectPosition.TopCenter:
1686 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1687 break;
1688 case RectPosition.BottomCenter:
1689 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1690 break;
1691 case RectPosition.TopLEFT:
1692 _rect.SetAnchor(0f, 1f, 0f, 1f);
1693 break;
1694 case RectPosition.TopRIGHT:
1695 _rect.SetAnchor(1f, 1f, 1f, 1f);
1696 break;
1697 case RectPosition.BottomLEFT:
1698 _rect.SetAnchor(0f, 0f, 0f, 0f);
1699 break;
1700 case RectPosition.BottomRIGHT:
1701 _rect.SetAnchor(1f, 0f, 1f, 0f);
1702 break;
1703 case RectPosition.Left:
1704 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1705 break;
1706 case RectPosition.Right:
1707 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1708 break;
1709 default:
1710 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1711 break;
1712 }
1713 }
1714
1715 public static void SetAnchor(this RectTransform _rect, RectPosition anchor = RectPosition.Auto)
1716 {
1717 Vector3 position = _rect.position;
1718 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1719 _rect.position = position;
1720 }
1721
1722 public static RectPosition GetAnchor(this RectTransform _rect)
1723 {
1724 Vector3 position = _rect.position;
1725 int width = Screen.width;
1726 int height = Screen.height;
1727 bool flag = position.y > (float)height * 0.5f;
1728 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1729 {
1730 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1731 {
1732 return RectPosition.Center;
1733 }
1734 if (!flag)
1735 {
1736 return RectPosition.BottomCenter;
1737 }
1738 return RectPosition.TopCenter;
1739 }
1740 if (position.x < (float)width * 0.5f)
1741 {
1742 if (!flag)
1743 {
1744 return RectPosition.BottomLEFT;
1745 }
1746 return RectPosition.TopLEFT;
1747 }
1748 if (!flag)
1749 {
1750 return RectPosition.BottomRIGHT;
1751 }
1752 return RectPosition.TopRIGHT;
1753 }
1754
1755 public static Transform GetLastChild(this Transform trans)
1756 {
1757 return trans.GetChild(trans.childCount - 1);
1758 }
1759
1760 public static Vector2 ToVector2(this Vector3 self)
1761 {
1762 return new Vector2(self.x, self.z);
1763 }
1764
1765 public static void SetScale(this SpriteRenderer renderer, float size)
1766 {
1767 float x = renderer.bounds.size.x;
1768 float y = renderer.bounds.size.y;
1769 float x2 = size / x;
1770 float y2 = size / y;
1771 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1772 }
1773
1774 private static float GetForwardDiffPoint(Vector2 forward)
1775 {
1776 if (object.Equals(forward, Vector2.up))
1777 {
1778 return 90f;
1779 }
1780 object.Equals(forward, Vector2.right);
1781 return 0f;
1782 }
1783
1784 public static void LookAt2D(this Transform self, Transform target, Vector2 forward)
1785 {
1786 self.LookAt2D(target.position, forward);
1787 }
1788
1789 public static void LookAt2D(this Transform self, Vector3 target, Vector2 forward)
1790 {
1791 float forwardDiffPoint = GetForwardDiffPoint(forward);
1792 Vector3 vector = target - self.position;
1793 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1794 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1795 }
1796
1797 public static float Distance(this Transform t, Vector2 pos)
1798 {
1799 return Vector3.Distance(t.position, pos);
1800 }
1801
1802 public static Vector3 Plus(this Vector3 v, Vector2 v2)
1803 {
1804 v.x += v2.x;
1805 v.y += v2.y;
1806 return v;
1807 }
1808
1809 public static Vector3 SetZ(this Vector3 v, float a)
1810 {
1811 v.z = a;
1812 return v;
1813 }
1814
1815 public static Vector3 SetY(this Vector3 v, float a)
1816 {
1817 v.y = a;
1818 return v;
1819 }
1820
1821 public static Vector3 PlusX(this Vector3 v, float a)
1822 {
1823 v.x += a;
1824 return v;
1825 }
1826
1827 public static Vector3 PlusY(this Vector3 v, float a)
1828 {
1829 v.y += a;
1830 return v;
1831 }
1832
1833 public static Vector3 PlusZ(this Vector3 v, float a)
1834 {
1835 v.z += a;
1836 return v;
1837 }
1838
1839 public static void SetPosition(this Transform transform, float x, float y, float z)
1840 {
1841 vector3.Set(x, y, z);
1842 transform.position = vector3;
1843 }
1844
1845 public static void SetPositionX(this Transform transform, float x)
1846 {
1847 vector3.Set(x, transform.position.y, transform.position.z);
1848 transform.position = vector3;
1849 }
1850
1851 public static void SetPositionY(this Transform transform, float y)
1852 {
1853 vector3.Set(transform.position.x, y, transform.position.z);
1854 transform.position = vector3;
1855 }
1856
1857 public static void SetPositionZ(this Transform transform, float z)
1858 {
1859 vector3.Set(transform.position.x, transform.position.y, z);
1860 transform.position = vector3;
1861 }
1862
1863 public static void AddPosition(this Transform transform, float x, float y, float z)
1864 {
1865 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1866 transform.position = vector3;
1867 }
1868
1869 public static void AddPositionX(this Transform transform, float x)
1870 {
1871 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1872 transform.position = vector3;
1873 }
1874
1875 public static void AddPositionY(this Transform transform, float y)
1876 {
1877 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1878 transform.position = vector3;
1879 }
1880
1881 public static void AddPositionZ(this Transform transform, float z)
1882 {
1883 vector3.Set(transform.position.x, transform.position.y, transform.position.z + z);
1884 transform.position = vector3;
1885 }
1886
1887 public static void SetLocalPosition(this Transform transform, float x, float y, float z)
1888 {
1889 vector3.Set(x, y, z);
1890 transform.localPosition = vector3;
1891 }
1892
1893 public static void SetLocalPositionX(this Transform transform, float x)
1894 {
1895 vector3.Set(x, transform.localPosition.y, transform.localPosition.z);
1896 transform.localPosition = vector3;
1897 }
1898
1899 public static void SetLocalPositionY(this Transform transform, float y)
1900 {
1901 vector3.Set(transform.localPosition.x, y, transform.localPosition.z);
1902 transform.localPosition = vector3;
1903 }
1904
1905 public static void SetLocalPositionZ(this Transform transform, float z)
1906 {
1907 vector3.Set(transform.localPosition.x, transform.localPosition.y, z);
1908 transform.localPosition = vector3;
1909 }
1910
1911 public static void AddLocalPosition(this Transform transform, float x, float y, float z)
1912 {
1913 vector3.Set(transform.localPosition.x + x, transform.localPosition.y + y, transform.localPosition.z + z);
1914 transform.localPosition = vector3;
1915 }
1916
1917 public static void AddLocalPositionX(this Transform transform, float x)
1918 {
1919 vector3.Set(transform.localPosition.x + x, transform.localPosition.y, transform.localPosition.z);
1920 transform.localPosition = vector3;
1921 }
1922
1923 public static void AddLocalPositionY(this Transform transform, float y)
1924 {
1925 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1926 transform.localPosition = vector3;
1927 }
1928
1929 public static void AddLocalPositionZ(this Transform transform, float z)
1930 {
1931 vector3.Set(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + z);
1932 transform.localPosition = vector3;
1933 }
1934
1935 public static void SetLocalScale(this Transform transform, float x, float y, float z)
1936 {
1937 vector3.Set(x, y, z);
1938 transform.localScale = vector3;
1939 }
1940
1941 public static void SetLocalScaleX(this Transform transform, float x)
1942 {
1943 vector3.Set(x, transform.localScale.y, transform.localScale.z);
1944 transform.localScale = vector3;
1945 }
1946
1947 public static void SetLocalScaleY(this Transform transform, float y)
1948 {
1949 vector3.Set(transform.localScale.x, y, transform.localScale.z);
1950 transform.localScale = vector3;
1951 }
1952
1953 public static void SetLocalScaleZ(this Transform transform, float z)
1954 {
1955 vector3.Set(transform.localScale.x, transform.localScale.y, z);
1956 transform.localScale = vector3;
1957 }
1958
1959 public static void AddLocalScale(this Transform transform, float x, float y, float z)
1960 {
1961 vector3.Set(transform.localScale.x + x, transform.localScale.y + y, transform.localScale.z + z);
1962 transform.localScale = vector3;
1963 }
1964
1965 public static void AddLocalScaleX(this Transform transform, float x)
1966 {
1967 vector3.Set(transform.localScale.x + x, transform.localScale.y, transform.localScale.z);
1968 transform.localScale = vector3;
1969 }
1970
1971 public static void AddLocalScaleY(this Transform transform, float y)
1972 {
1973 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1974 transform.localScale = vector3;
1975 }
1976
1977 public static void AddLocalScaleZ(this Transform transform, float z)
1978 {
1979 vector3.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z + z);
1980 transform.localScale = vector3;
1981 }
1982
1983 public static void SetEulerAngles(this Transform transform, float x, float y, float z)
1984 {
1985 vector3.Set(x, y, z);
1986 transform.eulerAngles = vector3;
1987 }
1988
1989 public static void SetEulerAnglesX(this Transform transform, float x)
1990 {
1991 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1992 transform.eulerAngles = vector3;
1993 }
1994
1995 public static void SetEulerAnglesY(this Transform transform, float y)
1996 {
1997 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1998 transform.eulerAngles = vector3;
1999 }
2000
2001 public static void SetEulerAnglesZ(this Transform transform, float z)
2002 {
2003 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
2004 transform.eulerAngles = vector3;
2005 }
2006
2007 public static void AddEulerAngles(this Transform transform, float x, float y, float z)
2008 {
2009 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
2010 transform.eulerAngles = vector3;
2011 }
2012
2013 public static void AddEulerAnglesX(this Transform transform, float x)
2014 {
2015 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
2016 transform.eulerAngles = vector3;
2017 }
2018
2019 public static void AddEulerAnglesY(this Transform transform, float y)
2020 {
2021 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
2022 transform.eulerAngles = vector3;
2023 }
2024
2025 public static void AddEulerAnglesZ(this Transform transform, float z)
2026 {
2027 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
2028 transform.eulerAngles = vector3;
2029 }
2030
2031 public static void SetLocalEulerAngles(this Transform transform, float x, float y, float z)
2032 {
2033 vector3.Set(x, y, z);
2034 transform.localEulerAngles = vector3;
2035 }
2036
2037 public static void SetLocalEulerAnglesX(this Transform transform, float x)
2038 {
2039 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2040 transform.localEulerAngles = vector3;
2041 }
2042
2043 public static void SetLocalEulerAnglesY(this Transform transform, float y)
2044 {
2045 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
2046 transform.localEulerAngles = vector3;
2047 }
2048
2049 public static void SetLocalEulerAnglesZ(this Transform transform, float z)
2050 {
2051 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
2052 transform.localEulerAngles = vector3;
2053 }
2054
2055 public static void AddLocalEulerAngles(this Transform transform, float x, float y, float z)
2056 {
2057 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
2058 transform.localEulerAngles = vector3;
2059 }
2060
2061 public static void AddLocalEulerAnglesX(this Transform transform, float x)
2062 {
2063 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2064 transform.localEulerAngles = vector3;
2065 }
2066
2067 public static void AddLocalEulerAnglesY(this Transform transform, float y)
2068 {
2069 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
2070 transform.localEulerAngles = vector3;
2071 }
2072
2073 public static void AddLocalEulerAnglesZ(this Transform transform, float z)
2074 {
2075 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z + z);
2076 transform.localEulerAngles = vector3;
2077 }
2078
2079 public static void ToggleKeyword(this Material m, string id, bool enable)
2080 {
2081 if (enable)
2082 {
2083 m.EnableKeyword(id);
2084 }
2085 else
2086 {
2087 m.DisableKeyword(id);
2088 }
2089 }
2090
2091 public static void ForeachReverse<T>(this IList<T> items, Action<T> action)
2092 {
2093 for (int num = items.Count - 1; num >= 0; num--)
2094 {
2095 action(items[num]);
2096 }
2097 }
2098
2099 public static void ForeachReverse<T>(this IList<T> items, Func<T, bool> action)
2100 {
2101 int num = items.Count - 1;
2102 while (num >= 0 && !action(items[num]))
2103 {
2104 num--;
2105 }
2106 }
2107
2108 public static bool RemoveFromEnd<T>(this List<T> items, T item)
2109 {
2110 int num = items.LastIndexOf(item);
2111 if (num < 0)
2112 {
2113 return false;
2114 }
2115 items.RemoveAt(num);
2116 return true;
2117 }
2118
2119 public static float ClampAngle(this float angle)
2120 {
2121 if (angle < 0f)
2122 {
2123 return 360f - (0f - angle) % 360f;
2124 }
2125 return angle % 360f;
2126 }
2127
2128 public static Vector3 Random(this Vector3 v)
2129 {
2130 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2131 }
2132
2133 public static T Instantiate<T>(this T s) where T : ScriptableObject
2134 {
2135 string name = s.name;
2136 T val = UnityEngine.Object.Instantiate(s);
2137 val.name = name;
2138 return val;
2139 }
2140
2141 public static int GetRuntimeEventCount(this UnityEventBase unityEvent)
2142 {
2143 Type typeFromHandle = typeof(UnityEventBase);
2144 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2145 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2146 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2147 Type type3 = typeof(List<>).MakeGenericType(type2);
2148 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2149 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2150 object value = field.GetValue(unityEvent);
2151 object value2 = field2.GetValue(value);
2152 return (int)type3.GetProperty("Count").GetValue(value2, null);
2153 }
2154}
ArticleStyle
Definition: ArticleStyle.cs:2
RectPosition
Definition: RectPosition.cs:2
static readonly Dictionary< string, T > fuzzy
static readonly Dictionary< string, T > cached
static readonly bool IsLong
static readonly bool IsInt
static string TryAddExtension(this string s, string ext)
static string StripLastPun(this string str)
static byte SetBit(this byte pByte, int bitNo, bool value)
static T GetComponentInChildrenExcludSelf< T >(this Transform c)
static int[] SplitToInts(this string str, char separator)
static void SetEulerAnglesZ(this Transform transform, float z)
static T CreateMold< T >(this Component c, string name=null)
static void SetAnchor(this RectTransform r, float minX, float minY, float maxX, float maxY)
static T GetField< T >(this object o, string name)
static void SetPosition(this Transform transform, float x, float y, float z)
static string TagColor(this string s, Color c, string txt)
static void SetEulerAnglesX(this Transform transform, float x)
static int NextIndex< TValue >(this IList< TValue > source, TValue val)
static string RemoveAllTags(this string text)
static int ClampMax(this int v, int max)
static void Each< TValue >(this IList< TValue > list, Action< TValue > action)
static void AddLocalPosition(this Transform transform, float x, float y, float z)
static T PrevEnum< T >(this T src)
static string langGame(this string s, string ref1, string ref2=null, string ref3=null, string ref4=null)
static Vector3 vector3
static string Pluralize(string s)
static TKey[] CopyKeys< TKey, TValue >(this IDictionary< TKey, TValue > dict)
static void AddLocalEulerAnglesY(this Transform transform, float y)
static IList< TValue > Shuffle< TValue >(this IList< TValue > list)
static string Parentheses(this string str)
static void AddLocalScale(this Transform transform, float x, float y, float z)
static string ToTitleCase(this string s, bool wholeText=false)
static T Find< T >(this Component c, string name=null, bool recursive=false)
static string Fit(this Text text, string s, string suffix="")
static TValue Clamp< TValue >(this IList< TValue > source, int i)
static TValue TryGetValue< TKey, TValue >(this IDictionary< TKey, TValue > source, TKey key, TValue fallback=default(TValue))
static void SetLocalEulerAngles(this Transform transform, float x, float y, float z)
static string ToFormat(this int a)
static void LoopSelectable(this List< Selectable > sels, bool vertical=true, bool horizonal=true, bool asGroup=true)
static string langPlural(this string s, int i)
static void SetScale(this SpriteRenderer renderer, float size)
static int ToInt(this string str, Type type)
static float GetForwardDiffPoint(Vector2 forward)
static T ToEnum< T >(this int value)
static bool IsChildOf(this GameObject c, GameObject root)
static int Calc(this string str, int power=0, int ele=0, int p2=0)
static void AddLocalScaleY(this Transform transform, float y)
static void SetSlider(this Slider slider, float value, Func< float, string > action, int min=-1, int max=-1, bool notify=true)
static string StripPun(this string str, bool stripComma, bool insertSpaceForComma=false)
static int IndexOf(this IList< Component > list, GameObject go)
static Vector3 SetY(this Vector3 v, float a)
static void AddPositionX(this Transform transform, float x)
static void LoopTail< T >(this List< T > list, bool vertical=false)
static T GetOrCreate< T >(this Component t)
static bool IsOn(this int data, int digit)
static IList< TValue > Copy< TValue >(this IList< TValue > list)
static float FromInt2(this int a)
static Selectable GetSelectable(this GameObject go)
static string AddArticle(this string s, int num, ArticleStyle style=ArticleStyle.Default, string replace=null)
static void SetLocalPositionZ(this Transform transform, float z)
static void SetLocalEulerAnglesZ(this Transform transform, float z)
static void RebuildLayoutTo(this Component c, Component target)
static bool IsEmpty(this string str)
static bool IsPrefab(this Component c)
static void SetActive(this Component c, bool enable)
static void ToDictionary< T >(this IList< UPair< T > > list, ref Dictionary< string, T > dic)
static string RemoveTag(this string s, string id, char splitter='/')
static void AddEulerAnglesZ(this Transform transform, float z)
static void SetProperty< T >(this object o, string name, T value)
static bool Within(this byte v, byte v2, byte range)
static void SetAlpha(this Text text, float aloha=1f)
static void ToggleActive(this Component c)
static bool Contains(this string[] strs, string id)
static int GetRuntimeEventCount(this UnityEventBase unityEvent)
static string[] SplitByNewline(this string text)
static void SetLayerRecursively(this GameObject obj, int layer)
static void SetActive(this Component c, bool enable, Action< bool > onChangeState)
static void SetLocalEulerAnglesY(this Transform transform, float y)
static bool Within(this int v, int v2, int range)
static Vector2 ToVector2(this Vector3 self)
static bool HasTag(this string s, string id, char splitter='/')
static void LoopSelectable(this Transform l, bool vertical=true, bool horizonal=true, bool asGroup=true)
static string[] langList(this string s)
static Color ToColor(this string s)
static void AddLocalEulerAnglesX(this Transform transform, float x)
static void SetLocalPosition(this Transform transform, float x, float y, float z)
static void AddPositionY(this Transform transform, float y)
static RectPosition GetAnchor(this RectTransform _rect)
static bool GetBit(this byte pByte, int bitNo)
static void ToggleKeyword(this Material m, string id, bool enable)
static string Tag(this Color c)
static T NextEnum< T >(this T src)
static void SetPositionX(this Transform transform, float x)
static void SetLocalScaleX(this Transform transform, float x)
static TValue GetOrCreate< TKey, TValue >(this IDictionary< TKey, TValue > dict, TKey key, Func< TValue > func=null)
static Vector3 PlusY(this Vector3 v, float a)
static bool IsEmpty(this Array array)
static T GetProperty< T >(this object o, string name)
static void SetLocalPositionX(this Transform transform, float x)
static void SetLocalEulerAnglesX(this Transform transform, float x)
static float Distance(this Transform t, Vector2 pos)
static void AddLocalScaleX(this Transform transform, float x)
static float FromInt3(this int a)
static void AddEulerAngles(this Transform transform, float x, float y, float z)
static string TagSize(this string s, int size)
static void AddLocalScaleZ(this Transform transform, float z)
static void SetAlpha(this RawImage c, float a)
static void AddEulerAnglesX(this Transform transform, float x)
static Transform Find(this Component c, string name=null)
static void DestroyChildren(this Component component, bool destroyInactive=false, bool ignoreDestroy=true)
static bool IsInteractable(this GameObject obj)
static void Sort< T >(this IList< T > list, Comparison< T > comparison)
static int ToInt3(this float a)
static TValue RandomItem< TKey, TValue >(this IDictionary< TKey, TValue > source)
static string StripBrackets(this string str)
static string ToHex(this Color c)
static TValue RandomItemWeighted< TValue >(this IList< TValue > source, Func< TValue, float > getWeight)
static string lang(this string s)
static float ToFloat(this string str)
static Vector3 SetZ(this Vector3 v, float a)
static void AddLocalEulerAnglesZ(this Transform transform, float z)
static bool IsNull(this object o)
static void SetAlpha(this Image c, float a)
static void SetAnchor(this RectTransform _rect, RectPosition anchor=RectPosition.Auto)
static bool IsMouseOver(this RectTransform r, Camera cam)
static Vector3 PlusX(this Vector3 v, float a)
static List< T > GetComponentsInDirectChildren< T >(this Transform comp, bool includeInactive=true)
static string RemoveNewline(this string text)
static void SetSlider(this Slider slider, float value, Func< float, string > action, bool notify)
static bool RemoveFromEnd< T >(this List< T > items, T item)
static string langGame(this string s)
static void SetNavigation(this Component a, Component b, bool vertical=false)
static TValue RandomItem< TValue >(this IList< TValue > source)
static void AddLocalEulerAngles(this Transform transform, float x, float y, float z)
static int ClampMin(this int v, int min)
static TValue FirstItem< TKey, TValue >(this IDictionary< TKey, TValue > source)
static void SetPivot(this RectTransform r, float x, float y)
static TValue NextItem< TValue >(this IList< TValue > source, ref int index)
static T FindMax< T >(this List< T > list, Func< T, int > func)
static void SetField< T >(this object o, string name, T value)
static TValue TryGet< TValue >(this IList< TValue > array, int index, int defIndex=-1)
static TValue Move< TValue >(this IList< TValue > list, TValue target, int a)
static T GetComponentInDirectChildren< T >(this Component comp)
static void SetRect(this RectTransform r, float x, float y, float w, float h, float pivotX, float pivotY, float minX, float minY, float maxX, float maxY)
static Type ToType(this string value)
static string AddTag(this string s, string id, char splitter='/')
static void ForeachReverse< T >(this IList< T > items, Action< T > action)
static string ToSentenceCase(this string s)
static TValue PrevItem< TValue >(this IList< TValue > source, TValue val)
static void RebuildLayout(this Component c, bool recursive=false)
static Vector3 Plus(this Vector3 v, Vector2 v2)
static GameObject FindTagInParents(this Component c, string tag, bool includeInactive=true)
static string GetFullFileNameWithoutExtension(this string path)
static int ToInt< T >(this string str)
static string ToShortNumber(this int a)
static void SetEulerAnglesY(this Transform transform, float y)
static IPluralize pluralizer
static void AddLocalPositionX(this Transform transform, float x)
static string IsEmpty(this string str, string defaultStr)
static void Set< T1, T2 >(this Dictionary< T1, T2 > dic, Dictionary< T1, T2 > from)
static T RandomItem< T >(this IEnumerable< T > ie)
static T Instantiate< T >(this T s)
static string TagSize(this string s, string txt, int size)
static string Repeat(this string str, int count)
static Transform GetLastChild(this Transform trans)
static int ToInt(this string str)
static void SetPositionY(this Transform transform, float y)
static string ToFormat(this long a)
static string ToText(this int a, bool skipIfZero=true)
static void _SetAnchor(this RectTransform _rect, RectPosition anchor)
static Vector3 Random(this Vector3 v)
static string SetTag(this string s, string id, bool enable, char splitter='/')
static string GetFullFileNameWithoutExtension(this FileInfo fileInfo)
static void SetListener(this Button.ButtonClickedEvent e, Action action)
static void RebuildLayoutTo< T >(this Component c)
static void SetOnClick(this Button b, Action action)
static string Bracket(this string str, int type=0)
static void AddPosition(this Transform transform, float x, float y, float z)
static RectTransform Rect(this Component c)
static void AddLocalPositionZ(this Transform transform, float z)
static long ToLong(this string str)
static string Evalute(this string[] array, float val)
static string lang(this string s, string ref1, string ref2=null, string ref3=null, string ref4=null, string ref5=null)
static int Minimum(this int i)
static string GetSpecialArticle(string a)
static void LookAt2D(this Transform self, Transform target, Vector2 forward)
static void SetLocalScaleZ(this Transform transform, float z)
static void SetEulerAngles(this Transform transform, float x, float y, float z)
static float ClampAngle(this float angle)
static int Clamp(this int v, int min, int max, bool loop=false)
static string TrimNewLines(this string text)
static string TagColor(this string s, Color c)
static string[] SplitNewline(this string str)
static void CopyRect(this RectTransform r, RectTransform t)
static Color Multiply(this Color c, float mtp, float add)
static TValue[] CopyValues< TKey, TValue >(this IDictionary< TKey, TValue > dict)
static void SetLocalPositionY(this Transform transform, float y)
static Vector3 PlusZ(this Vector3 v, float a)
static void SetPositionZ(this Transform transform, float z)
static Color SetAlpha(this Color c, float a)
static void SetLocalScaleY(this Transform transform, float y)
static TValue LastItem< TValue >(this IList< TValue > source)
static byte[] ToBytes(this BitArray bits)
static T ToField< T >(this string s, object o)
static void SetLocalScale(this Transform transform, float x, float y, float z)
static string AddArticle(this string s)
static TValue Remainder< TValue >(this IList< TValue > source, int divider)
static int ToInt2(this float a)
static List< T > GetList< T >(this IDictionary source)
static void AddLocalPositionY(this Transform transform, float y)
static void AddPositionZ(this Transform transform, float z)
static bool HasField< T >(this object o, string name)
static void AddEulerAnglesY(this Transform transform, float y)
static void LookAt2D(this Transform self, Vector3 target, Vector2 forward)
bool pluralize
Definition: LangSetting.cs:32
bool addArticle
Definition: LangSetting.cs:30
bool capitalize
Definition: LangSetting.cs:34
char period
Definition: Lang.cs:20
char comma
Definition: Lang.cs:18
Definition: Lang.cs:7
static Words words
Definition: Lang.cs:27
static LangSetting setting
Definition: Lang.cs:55
static string Get(string id)
Definition: Lang.cs:90
static string[] GetList(string id)
Definition: Lang.cs:113
static LangGame Game
Definition: Lang.cs:49
static string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null, string val5=null)
Definition: Lang.cs:146
Definition: Rand.cs:4
static Random _random
Definition: Rand.cs:9
static int Range(int min, int max)
Definition: Rand.cs:49
static int rnd(int max)
Definition: Rand.cs:59
string Get(string id)
Definition: SourceLang.cs:12
string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null)
Definition: SourceLang.cs:43
Definition: UPair.cs:5
void SetInt(int i)
Definition: BitArray32.cs:89