Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
ClassExtension Class Reference

Static Public Member Functions

static string lang (this string s)
 
static string langPlural (this string s, int i)
 
static string lang (this string s, string ref1, string ref2=null, string ref3=null, string ref4=null, string ref5=null)
 
static string langGame (this string s)
 
static string langGame (this string s, string ref1, string ref2=null, string ref3=null, string ref4=null)
 
static string Parentheses (this string str)
 
static string Bracket (this string str, int type=0)
 
static byte[] ToBytes (this BitArray bits)
 
static bool GetBit (this byte pByte, int bitNo)
 
static byte SetBit (this byte pByte, int bitNo, bool value)
 
static int ToInt3 (this float a)
 
static float FromInt3 (this int a)
 
static int ToInt2 (this float a)
 
static float FromInt2 (this int a)
 
static int Minimum (this int i)
 
static bool IsNull (this object o)
 
static bool IsOn (this int data, int digit)
 
static T ToEnum< T > (this int value)
 
static T ToEnum< T > (this long value)
 
static T ToEnum< T > (this string value, bool ignoreCase=true)
 
static Type ToType (this string value)
 
static T NextEnum< T > (this T src)
 
static T PrevEnum< T > (this T src)
 
static bool Within (this int v, int v2, int range)
 
static bool Within (this byte v, byte v2, byte range)
 
static int Clamp (this int v, int min, int max, bool loop=false)
 
static int ClampMin (this int v, int min)
 
static int ClampMax (this int v, int max)
 
static T ToField< T > (this string s, object o)
 
static bool HasField< T > (this object o, string name)
 
static T GetField< T > (this object o, string name)
 
static void SetField< T > (this object o, string name, T value)
 
static T GetProperty< T > (this object o, string name)
 
static void SetProperty< T > (this object o, string name, T value)
 
static void Sort< T > (this IList< T > list, Comparison< T > comparison)
 
static TValue TryGet< TValue > (this IList< TValue > array, int index, int defIndex=-1)
 
static TValue TryGet< TValue > (this IList< TValue > array, int index, bool returnNull)
 
static bool IsEmpty (this Array array)
 
static int IndexOf (this IList< Component > list, GameObject go)
 
static TValue Move< TValue > (this IList< TValue > list, TValue target, int a)
 
static IList< TValue > Copy< TValue > (this IList< TValue > list)
 
static void Each< TValue > (this IList< TValue > list, Action< TValue > action)
 
static IList< TValue > Shuffle< TValue > (this IList< TValue > list)
 
static TValue TryGetValue< TKey, TValue > (this IDictionary< TKey, TValue > source, TKey key, TValue fallback=default(TValue))
 
static TValue TryGetValue< TKey, TValue > (this IDictionary< TKey, TValue > source, TKey key, TKey key_fallback)
 
static TValue GetOrCreate< TKey, TValue > (this IDictionary< TKey, TValue > dict, TKey key, Func< TValue > func=null)
 
static TKey[] CopyKeys< TKey, TValue > (this IDictionary< TKey, TValue > dict)
 
static TValue[] CopyValues< TKey, TValue > (this IDictionary< TKey, TValue > dict)
 
static T RandomItem< T > (this IEnumerable< T > ie)
 
static TValue RandomItem< TKey, TValue > (this IDictionary< TKey, TValue > source)
 
static TValue RandomItem< TValue > (this IList< TValue > source)
 
static TValue RandomItem< TValue > (this IList< TValue > source, TValue exclude)
 
static TValue RandomItem< TValue > (this IList< TValue > source, int exclude)
 
static TValue RandomItem< TValue > (this IList< TValue > source, Func< TValue, bool > funcValid, TValue defaultValue=default(TValue))
 
static TValue RandomItemWeighted< TValue > (this IList< TValue > source, Func< TValue, float > getWeight)
 
static TValue Remainder< TValue > (this IList< TValue > source, int divider)
 
static TValue FirstItem< TKey, TValue > (this IDictionary< TKey, TValue > source)
 
static TValue LastItem< TValue > (this IList< TValue > source)
 
static TValue NextItem< TValue > (this IList< TValue > source, ref int index)
 
static int NextIndex< TValue > (this IList< TValue > source, TValue val)
 
static TValue NextItem< TValue > (this IList< TValue > source, TValue val)
 
static TValue PrevItem< TValue > (this IList< TValue > source, TValue val)
 
static TValue Clamp< TValue > (this IList< TValue > source, int i)
 
static List< T > GetList< T > (this IDictionary source)
 
static void ToDictionary< T > (this IList< UPair< T > > list, ref Dictionary< string, T > dic)
 
static T FindMax< T > (this List< T > list, Func< T, int > func)
 
static void Set< T1, T2 > (this Dictionary< T1, T2 > dic, Dictionary< T1, T2 > from)
 
static int Calc (this string str, int power=0, int ele=0, int p2=0)
 
static int ToInt< T > (this string str)
 
static int ToInt (this string str, Type type)
 
static int ToInt (this string str)
 
static float ToFloat (this string str)
 
static string StripLastPun (this string str)
 
static string StripPun (this string str, bool stripComma, bool insertSpaceForComma=false)
 
static string Repeat (this string str, int count)
 
static string StripBrackets (this string str)
 
static string TryAddExtension (this string s, string ext)
 
static bool IsEmpty (this string str)
 
static string IsEmpty (this string str, string defaultStr)
 
static string TrimNewLines (this string text)
 
static int[] SplitToInts (this string str, char separator)
 
static string[] SplitNewline (this string str)
 
static bool Contains (this string[] strs, string id)
 
static string Evalute (this string[] array, float val)
 
static string ToShortNumber (this int a)
 
static string ToFormat (this int a)
 
static string ToFormat (this long a)
 
static string ToText (this int a, bool skipIfZero=true)
 
static string TagColor (this string s, Color c, string txt)
 
static string TagColor (this string s, Color c)
 
static string TagSize (this string s, string txt, int size)
 
static string TagSize (this string s, int size)
 
static string GetFullFileNameWithoutExtension (this FileInfo fileInfo)
 
static string GetFullFileNameWithoutExtension (this string path)
 
static string AddArticle (this string s)
 
static string AddArticle (this string s, int num, ArticleStyle style=ArticleStyle.Default, string replace=null)
 
static string ToTitleCase (this string s, bool wholeText=false)
 
static void LoopTail< T > (this List< T > list, bool vertical=false)
 
static void SetNavigation (this Component a, Component b, bool vertical=false)
 
static void LoopSelectable (this List< Selectable > sels, bool vertical=true, bool horizonal=true, bool asGroup=true)
 
static void LoopSelectable (this Transform l, bool vertical=true, bool horizonal=true, bool asGroup=true)
 
static Color ToColor (this string s)
 
static void SetAlpha (this Image c, float a)
 
static void SetAlpha (this RawImage c, float a)
 
static Color SetAlpha (this Color c, float a)
 
static Color Multiply (this Color c, float mtp, float add)
 
static string Tag (this Color c)
 
static string ToHex (this Color c)
 
static void SetOnClick (this Button b, Action action)
 
static void SetListener (this Button.ButtonClickedEvent e, Action action)
 
static void SetAlpha (this Text text, float aloha=1f)
 
static void SetSlider (this Slider slider, float value, Func< float, string > action, bool notify)
 
static void SetSlider (this Slider slider, float value, Func< float, string > action, int min=-1, int max=-1, bool notify=true)
 
static T GetOrCreate< T > (this Component t)
 
static RectTransform Rect (this Component c)
 
static void CopyRect (this RectTransform r, RectTransform t)
 
static void ToggleActive (this Component c)
 
static void SetActive (this Component c, bool enable)
 
static void SetActive (this Component c, bool enable, Action< bool > onChangeState)
 
static Selectable GetSelectable (this GameObject go)
 
static void SetLayerRecursively (this GameObject obj, int layer)
 
static bool IsInteractable (this GameObject obj)
 
static bool IsChildOf (this GameObject c, GameObject root)
 
static bool IsPrefab (this Component c)
 
static T CreateMold< T > (this Component c, string name=null)
 
static Transform Find (this Component c, string name=null)
 
static T Find< T > (this Component c, string name=null, bool recursive=false)
 
static GameObject FindTagInParents (this Component c, string tag, bool includeInactive=true)
 
static T GetComponentInChildrenExcludSelf< T > (this Transform c)
 
static List< T > GetComponentsInDirectChildren< T > (this Transform comp, bool includeInactive=true)
 
static List< T > GetComponentsInDirectChildren< T > (this Component comp, bool includeInactive=true)
 
static T GetComponentInDirectChildren< T > (this Component comp)
 
static void DestroyChildren (this Component component, bool destroyInactive=false, bool ignoreDestroy=true)
 
static bool IsMouseOver (this RectTransform r, Camera cam)
 
static void RebuildLayout (this Component c, bool recursive=false)
 
static void RebuildLayoutTo< T > (this Component c)
 
static void RebuildLayoutTo (this Component c, Component target)
 
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 void SetPivot (this RectTransform r, float x, float y)
 
static void SetAnchor (this RectTransform r, float minX, float minY, float maxX, float maxY)
 
static void _SetAnchor (this RectTransform _rect, RectPosition anchor)
 
static void SetAnchor (this RectTransform _rect, RectPosition anchor=RectPosition.Auto)
 
static RectPosition GetAnchor (this RectTransform _rect)
 
static Transform GetLastChild (this Transform trans)
 
static Vector2 ToVector2 (this Vector3 self)
 
static void SetScale (this SpriteRenderer renderer, float size)
 
static void LookAt2D (this Transform self, Transform target, Vector2 forward)
 
static void LookAt2D (this Transform self, Vector3 target, Vector2 forward)
 
static float Distance (this Transform t, Vector2 pos)
 
static Vector3 Plus (this Vector3 v, Vector2 v2)
 
static Vector3 SetZ (this Vector3 v, float a)
 
static Vector3 SetY (this Vector3 v, float a)
 
static Vector3 PlusX (this Vector3 v, float a)
 
static Vector3 PlusY (this Vector3 v, float a)
 
static Vector3 PlusZ (this Vector3 v, float a)
 
static void SetPosition (this Transform transform, float x, float y, float z)
 
static void SetPositionX (this Transform transform, float x)
 
static void SetPositionY (this Transform transform, float y)
 
static void SetPositionZ (this Transform transform, float z)
 
static void AddPosition (this Transform transform, float x, float y, float z)
 
static void AddPositionX (this Transform transform, float x)
 
static void AddPositionY (this Transform transform, float y)
 
static void AddPositionZ (this Transform transform, float z)
 
static void SetLocalPosition (this Transform transform, float x, float y, float z)
 
static void SetLocalPositionX (this Transform transform, float x)
 
static void SetLocalPositionY (this Transform transform, float y)
 
static void SetLocalPositionZ (this Transform transform, float z)
 
static void AddLocalPosition (this Transform transform, float x, float y, float z)
 
static void AddLocalPositionX (this Transform transform, float x)
 
static void AddLocalPositionY (this Transform transform, float y)
 
static void AddLocalPositionZ (this Transform transform, float z)
 
static void SetLocalScale (this Transform transform, float x, float y, float z)
 
static void SetLocalScaleX (this Transform transform, float x)
 
static void SetLocalScaleY (this Transform transform, float y)
 
static void SetLocalScaleZ (this Transform transform, float z)
 
static void AddLocalScale (this Transform transform, float x, float y, float z)
 
static void AddLocalScaleX (this Transform transform, float x)
 
static void AddLocalScaleY (this Transform transform, float y)
 
static void AddLocalScaleZ (this Transform transform, float z)
 
static void SetEulerAngles (this Transform transform, float x, float y, float z)
 
static void SetEulerAnglesX (this Transform transform, float x)
 
static void SetEulerAnglesY (this Transform transform, float y)
 
static void SetEulerAnglesZ (this Transform transform, float z)
 
static void AddEulerAngles (this Transform transform, float x, float y, float z)
 
static void AddEulerAnglesX (this Transform transform, float x)
 
static void AddEulerAnglesY (this Transform transform, float y)
 
static void AddEulerAnglesZ (this Transform transform, float z)
 
static void SetLocalEulerAngles (this Transform transform, float x, float y, float z)
 
static void SetLocalEulerAnglesX (this Transform transform, float x)
 
static void SetLocalEulerAnglesY (this Transform transform, float y)
 
static void SetLocalEulerAnglesZ (this Transform transform, float z)
 
static void AddLocalEulerAngles (this Transform transform, float x, float y, float z)
 
static void AddLocalEulerAnglesX (this Transform transform, float x)
 
static void AddLocalEulerAnglesY (this Transform transform, float y)
 
static void AddLocalEulerAnglesZ (this Transform transform, float z)
 
static void ToggleKeyword (this Material m, string id, bool enable)
 
static void ForeachReverse< T > (this IList< T > items, Action< T > action)
 
static void ForeachReverse< T > (this IList< T > items, Func< T, bool > action)
 
static float ClampAngle (this float angle)
 
static Vector3 Random (this Vector3 v)
 
static T Instantiate< T > (this T s)
 
static int GetRuntimeEventCount (this UnityEventBase unityEvent)
 

Static Public Attributes

static IPluralize pluralizer = new Pluralizer()
 

Static Private Member Functions

static float GetForwardDiffPoint (Vector2 forward)
 

Static Private Attributes

static Vector3 vector3
 

Detailed Description

Definition at line 13 of file ClassExtension.cs.

Member Function Documentation

◆ _SetAnchor()

static void ClassExtension._SetAnchor ( this RectTransform  _rect,
RectPosition  anchor 
)
inlinestatic

Definition at line 1464 of file ClassExtension.cs.

1465 {
1466 switch (anchor)
1467 {
1468 case RectPosition.TopCenter:
1469 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1470 break;
1471 case RectPosition.BottomCenter:
1472 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1473 break;
1474 case RectPosition.TopLEFT:
1475 _rect.SetAnchor(0f, 1f, 0f, 1f);
1476 break;
1477 case RectPosition.TopRIGHT:
1478 _rect.SetAnchor(1f, 1f, 1f, 1f);
1479 break;
1480 case RectPosition.BottomLEFT:
1481 _rect.SetAnchor(0f, 0f, 0f, 0f);
1482 break;
1483 case RectPosition.BottomRIGHT:
1484 _rect.SetAnchor(1f, 0f, 1f, 0f);
1485 break;
1486 case RectPosition.Left:
1487 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1488 break;
1489 case RectPosition.Right:
1490 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1491 break;
1492 default:
1493 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1494 break;
1495 }
1496 }
RectPosition
Definition: RectPosition.cs:2

◆ AddArticle() [1/2]

static string ClassExtension.AddArticle ( this string  s)
inlinestatic

Definition at line 897 of file ClassExtension.cs.

898 {
899 if (!Lang.setting.addArticle || s.Length < 1)
900 {
901 return s;
902 }
903 char c = s[0];
904 s = ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ") + s;
905 return s;
906 }
bool addArticle
Definition: LangSetting.cs:30
Definition: Lang.cs:6
static LangSetting setting
Definition: Lang.cs:54

References LangSetting.addArticle, and Lang.setting.

◆ AddArticle() [2/2]

static string ClassExtension.AddArticle ( this string  s,
int  num,
ArticleStyle  style = ArticleStyle::Default,
string  replace = null 
)
inlinestatic

Definition at line 908 of file ClassExtension.cs.

909 {
910 if (!Lang.setting.addArticle || s.Length < 1)
911 {
912 return s;
913 }
914 char c = s[0];
915 string text = ((num >= 2) ? (num.ToFormat() + " ") : ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a "));
916 if (num >= 2 && Lang.setting.pluralize)
917 {
918 s = ((replace.IsEmpty() || !s.Contains(replace) || s.Contains("limestone stone")) ? pluralizer.Pluralize(s) : s.Replace(replace, pluralizer.Pluralize(replace)));
919 }
920 return style switch
921 {
922 ArticleStyle.The => "_the".lang().ToTitleCase() + " " + ((num > 1) ? (num + " ") : "") + s,
923 ArticleStyle.None => ((num > 1) ? (num.ToFormat() + " ") : "") + s.ToTitleCase(),
924 _ => text + s,
925 };
926 }
ArticleStyle
Definition: ArticleStyle.cs:2
static IPluralize pluralizer
bool pluralize
Definition: LangSetting.cs:32

References LangSetting.addArticle, LangSetting.pluralize, pluralizer, and Lang.setting.

◆ AddEulerAngles()

static void ClassExtension.AddEulerAngles ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1790 of file ClassExtension.cs.

1791 {
1792 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1793 transform.eulerAngles = vector3;
1794 }
static Vector3 vector3

References vector3.

◆ AddEulerAnglesX()

static void ClassExtension.AddEulerAnglesX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1796 of file ClassExtension.cs.

1797 {
1798 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
1799 transform.eulerAngles = vector3;
1800 }

References vector3.

◆ AddEulerAnglesY()

static void ClassExtension.AddEulerAnglesY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1802 of file ClassExtension.cs.

1803 {
1804 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
1805 transform.eulerAngles = vector3;
1806 }

References vector3.

◆ AddEulerAnglesZ()

static void ClassExtension.AddEulerAnglesZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1808 of file ClassExtension.cs.

1809 {
1810 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
1811 transform.eulerAngles = vector3;
1812 }

References vector3.

◆ AddLocalEulerAngles()

static void ClassExtension.AddLocalEulerAngles ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1838 of file ClassExtension.cs.

1839 {
1840 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
1841 transform.localEulerAngles = vector3;
1842 }

References vector3.

◆ AddLocalEulerAnglesX()

static void ClassExtension.AddLocalEulerAnglesX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1844 of file ClassExtension.cs.

1845 {
1846 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1847 transform.localEulerAngles = vector3;
1848 }

References vector3.

◆ AddLocalEulerAnglesY()

static void ClassExtension.AddLocalEulerAnglesY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1850 of file ClassExtension.cs.

1851 {
1852 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
1853 transform.localEulerAngles = vector3;
1854 }

References vector3.

◆ AddLocalEulerAnglesZ()

static void ClassExtension.AddLocalEulerAnglesZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1856 of file ClassExtension.cs.

1857 {
1858 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z + z);
1859 transform.localEulerAngles = vector3;
1860 }

References vector3.

◆ AddLocalPosition()

static void ClassExtension.AddLocalPosition ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1694 of file ClassExtension.cs.

1695 {
1696 vector3.Set(transform.localPosition.x + x, transform.localPosition.y + y, transform.localPosition.z + z);
1697 transform.localPosition = vector3;
1698 }

References vector3.

◆ AddLocalPositionX()

static void ClassExtension.AddLocalPositionX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1700 of file ClassExtension.cs.

1701 {
1702 vector3.Set(transform.localPosition.x + x, transform.localPosition.y, transform.localPosition.z);
1703 transform.localPosition = vector3;
1704 }

References vector3.

◆ AddLocalPositionY()

static void ClassExtension.AddLocalPositionY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1706 of file ClassExtension.cs.

1707 {
1708 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1709 transform.localPosition = vector3;
1710 }

References vector3.

◆ AddLocalPositionZ()

static void ClassExtension.AddLocalPositionZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1712 of file ClassExtension.cs.

1713 {
1714 vector3.Set(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + z);
1715 transform.localPosition = vector3;
1716 }

References vector3.

◆ AddLocalScale()

static void ClassExtension.AddLocalScale ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1742 of file ClassExtension.cs.

1743 {
1744 vector3.Set(transform.localScale.x + x, transform.localScale.y + y, transform.localScale.z + z);
1745 transform.localScale = vector3;
1746 }

References vector3.

◆ AddLocalScaleX()

static void ClassExtension.AddLocalScaleX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1748 of file ClassExtension.cs.

1749 {
1750 vector3.Set(transform.localScale.x + x, transform.localScale.y, transform.localScale.z);
1751 transform.localScale = vector3;
1752 }

References vector3.

◆ AddLocalScaleY()

static void ClassExtension.AddLocalScaleY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1754 of file ClassExtension.cs.

1755 {
1756 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1757 transform.localScale = vector3;
1758 }

References vector3.

◆ AddLocalScaleZ()

static void ClassExtension.AddLocalScaleZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1760 of file ClassExtension.cs.

1761 {
1762 vector3.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z + z);
1763 transform.localScale = vector3;
1764 }

References vector3.

◆ AddPosition()

static void ClassExtension.AddPosition ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1646 of file ClassExtension.cs.

1647 {
1648 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1649 transform.position = vector3;
1650 }

References vector3.

◆ AddPositionX()

static void ClassExtension.AddPositionX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1652 of file ClassExtension.cs.

1653 {
1654 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1655 transform.position = vector3;
1656 }

References vector3.

◆ AddPositionY()

static void ClassExtension.AddPositionY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1658 of file ClassExtension.cs.

1659 {
1660 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1661 transform.position = vector3;
1662 }

References vector3.

◆ AddPositionZ()

static void ClassExtension.AddPositionZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1664 of file ClassExtension.cs.

1665 {
1666 vector3.Set(transform.position.x, transform.position.y, transform.position.z + z);
1667 transform.position = vector3;
1668 }

References vector3.

◆ Bracket()

static string ClassExtension.Bracket ( this string  str,
int  type = 0 
)
inlinestatic

Definition at line 50 of file ClassExtension.cs.

51 {
52 return type switch
53 {
54 -1 => str,
55 1 => "「" + str + "」",
56 2 => "『" + str + "』",
57 3 => "《" + str + "》",
58 4 => "(" + str + ")",
59 _ => "_bracketLeft".lang() + str + "_bracketRight".lang(),
60 };
61 }

◆ Calc()

static int ClassExtension.Calc ( this string  str,
int  power = 0,
int  ele = 0,
int  p2 = 0 
)
inlinestatic

Definition at line 638 of file ClassExtension.cs.

639 {
640 return Cal.Calcuate(str.Replace("p2", p2.ToString() ?? "").Replace("p", power.ToString() ?? "").Replace("e", ele.ToString() ?? ""));
641 }

◆ Clamp()

static int ClassExtension.Clamp ( this int  v,
int  min,
int  max,
bool  loop = false 
)
inlinestatic

Definition at line 177 of file ClassExtension.cs.

178 {
179 if (v < min)
180 {
181 v = ((!loop) ? min : max);
182 }
183 else if (v > max)
184 {
185 v = ((!loop) ? max : min);
186 }
187 return v;
188 }

◆ Clamp< TValue >()

static TValue ClassExtension.Clamp< TValue > ( this IList< TValue >  source,
int  i 
)
inlinestatic

Definition at line 578 of file ClassExtension.cs.

579 {
580 if (i < 0)
581 {
582 i = 0;
583 }
584 else if (i >= source.Count)
585 {
586 i = source.Count - 1;
587 }
588 return source[i];
589 }

◆ ClampAngle()

static float ClassExtension.ClampAngle ( this float  angle)
inlinestatic

Definition at line 1891 of file ClassExtension.cs.

1892 {
1893 if (angle < 0f)
1894 {
1895 return 360f - (0f - angle) % 360f;
1896 }
1897 return angle % 360f;
1898 }

◆ ClampMax()

static int ClassExtension.ClampMax ( this int  v,
int  max 
)
inlinestatic

Definition at line 199 of file ClassExtension.cs.

200 {
201 if (v <= max)
202 {
203 return v;
204 }
205 return max;
206 }

◆ ClampMin()

static int ClassExtension.ClampMin ( this int  v,
int  min 
)
inlinestatic

Definition at line 190 of file ClassExtension.cs.

191 {
192 if (v >= min)
193 {
194 return v;
195 }
196 return min;
197 }

◆ Contains()

static bool ClassExtension.Contains ( this string[]  strs,
string  id 
)
inlinestatic

Definition at line 792 of file ClassExtension.cs.

793 {
794 if (strs == null || strs.Length == 0)
795 {
796 return false;
797 }
798 for (int i = 0; i < strs.Length; i++)
799 {
800 if (strs[i] == id)
801 {
802 return true;
803 }
804 }
805 return false;
806 }

◆ Copy< TValue >()

static IList< TValue > ClassExtension.Copy< TValue > ( this IList< TValue >  list)
inlinestatic

Definition at line 330 of file ClassExtension.cs.

331 {
332 return list.ToList();
333 }

◆ CopyKeys< TKey, TValue >()

static TKey[] ClassExtension.CopyKeys< TKey, TValue > ( this IDictionary< TKey, TValue >  dict)
inlinestatic

Definition at line 388 of file ClassExtension.cs.

389 {
390 TKey[] array = new TKey[dict.Keys.Count];
391 dict.Keys.CopyTo(array, 0);
392 return array;
393 }

◆ CopyRect()

static void ClassExtension.CopyRect ( this RectTransform  r,
RectTransform  t 
)
inlinestatic

Definition at line 1192 of file ClassExtension.cs.

1193 {
1194 r.pivot = t.pivot;
1195 r.sizeDelta = t.sizeDelta;
1196 r.anchorMin = t.anchorMin;
1197 r.anchorMax = t.anchorMax;
1198 r.anchoredPosition = t.anchoredPosition;
1199 }

◆ CopyValues< TKey, TValue >()

static TValue[] ClassExtension.CopyValues< TKey, TValue > ( this IDictionary< TKey, TValue >  dict)
inlinestatic

Definition at line 395 of file ClassExtension.cs.

396 {
397 TValue[] array = new TValue[dict.Keys.Count];
398 dict.Values.CopyTo(array, 0);
399 return array;
400 }

◆ CreateMold< T >()

static T ClassExtension.CreateMold< T > ( this Component  c,
string  name = null 
)
inlinestatic
Type Constraints
T :Component 

Definition at line 1265 of file ClassExtension.cs.

1265 : Component
1266 {
1267 T result = null;
1268 for (int i = 0; i < c.transform.childCount; i++)
1269 {
1270 T component = c.transform.GetChild(i).GetComponent<T>();
1271 if ((bool)component && (name.IsEmpty() || name == component.name))
1272 {
1273 component.gameObject.SetActive(value: false);
1274 result = component;
1275 break;
1276 }
1277 }
1278 c.DestroyChildren();
1279 return result;
1280 }

◆ DestroyChildren()

static void ClassExtension.DestroyChildren ( this Component  component,
bool  destroyInactive = false,
bool  ignoreDestroy = true 
)
inlinestatic

Definition at line 1387 of file ClassExtension.cs.

1388 {
1389 if (!component || !component.transform)
1390 {
1391 Debug.LogWarning("DestroyChlidren:" + component);
1392 return;
1393 }
1394 for (int num = component.transform.childCount - 1; num >= 0; num--)
1395 {
1396 GameObject gameObject = component.transform.GetChild(num).gameObject;
1397 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1398 {
1399 UnityEngine.Object.DestroyImmediate(gameObject);
1400 }
1401 }
1402 }

References Debug.

◆ Distance()

static float ClassExtension.Distance ( this Transform  t,
Vector2  pos 
)
inlinestatic

Definition at line 1580 of file ClassExtension.cs.

1581 {
1582 return Vector3.Distance(t.position, pos);
1583 }

◆ Each< TValue >()

static void ClassExtension.Each< TValue > ( this IList< TValue >  list,
Action< TValue >  action 
)
inlinestatic

Definition at line 335 of file ClassExtension.cs.

336 {
337 for (int num = list.Count - 1; num >= 0; num--)
338 {
339 action(list[num]);
340 }
341 }

◆ Evalute()

static string ClassExtension.Evalute ( this string[]  array,
float  val 
)
inlinestatic

Definition at line 808 of file ClassExtension.cs.

809 {
810 return array[(int)Mathf.Clamp((float)(array.Length - 1) * val, 0f, array.Length - 1)];
811 }

◆ Find()

static Transform ClassExtension.Find ( this Component  c,
string  name = null 
)
inlinestatic

Definition at line 1282 of file ClassExtension.cs.

1283 {
1284 return c.Find<Transform>(name);
1285 }

◆ Find< T >()

static T ClassExtension.Find< T > ( this Component  c,
string  name = null,
bool  recursive = false 
)
inlinestatic
Type Constraints
T :Component 

Definition at line 1287 of file ClassExtension.cs.

1287 : Component
1288 {
1289 if (recursive)
1290 {
1291 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1292 foreach (T val in componentsInChildren)
1293 {
1294 if (name == null || name == val.name)
1295 {
1296 return val;
1297 }
1298 }
1299 return null;
1300 }
1301 for (int j = 0; j < c.transform.childCount; j++)
1302 {
1303 T component = c.transform.GetChild(j).GetComponent<T>();
1304 if ((bool)component && (name == null || name == component.name))
1305 {
1306 return component;
1307 }
1308 }
1309 return null;
1310 }

◆ FindMax< T >()

static T ClassExtension.FindMax< T > ( this List< T >  list,
Func< T, int >  func 
)
inlinestatic

Definition at line 613 of file ClassExtension.cs.

614 {
615 int num = int.MinValue;
616 T result = default(T);
617 foreach (T item in list)
618 {
619 int num2 = func(item);
620 if (num2 > num)
621 {
622 num = num2;
623 result = item;
624 }
625 }
626 return result;
627 }

References item.

◆ FindTagInParents()

static GameObject ClassExtension.FindTagInParents ( this Component  c,
string  tag,
bool  includeInactive = true 
)
inlinestatic

Definition at line 1312 of file ClassExtension.cs.

1313 {
1314 Transform transform = c.transform;
1315 for (int i = 0; i < transform.childCount; i++)
1316 {
1317 Transform child = transform.GetChild(i);
1318 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1319 {
1320 return child.gameObject;
1321 }
1322 }
1323 if ((bool)transform.parent)
1324 {
1325 return transform.parent.FindTagInParents(tag, includeInactive);
1326 }
1327 return null;
1328 }

◆ FirstItem< TKey, TValue >()

static TValue ClassExtension.FirstItem< TKey, TValue > ( this IDictionary< TKey, TValue >  source)
inlinestatic

Definition at line 504 of file ClassExtension.cs.

505 {
506 if (source == null)
507 {
508 return default(TValue);
509 }
510 return source[source.First().Key];
511 }

◆ ForeachReverse< T >() [1/2]

static void ClassExtension.ForeachReverse< T > ( this IList< T >  items,
Action< T >  action 
)
inlinestatic

Definition at line 1874 of file ClassExtension.cs.

1875 {
1876 for (int num = items.Count - 1; num >= 0; num--)
1877 {
1878 action(items[num]);
1879 }
1880 }

◆ ForeachReverse< T >() [2/2]

static void ClassExtension.ForeachReverse< T > ( this IList< T >  items,
Func< T, bool >  action 
)
inlinestatic

Definition at line 1882 of file ClassExtension.cs.

1883 {
1884 int num = items.Count - 1;
1885 while (num >= 0 && !action(items[num]))
1886 {
1887 num--;
1888 }
1889 }

◆ FromInt2()

static float ClassExtension.FromInt2 ( this int  a)
inlinestatic

Definition at line 99 of file ClassExtension.cs.

100 {
101 return (float)a / 100f;
102 }

◆ FromInt3()

static float ClassExtension.FromInt3 ( this int  a)
inlinestatic

Definition at line 89 of file ClassExtension.cs.

90 {
91 return (float)a / 1000f;
92 }

◆ GetAnchor()

static RectPosition ClassExtension.GetAnchor ( this RectTransform  _rect)
inlinestatic

Definition at line 1505 of file ClassExtension.cs.

1506 {
1507 Vector3 position = _rect.position;
1508 int width = Screen.width;
1509 int height = Screen.height;
1510 bool flag = position.y > (float)height * 0.5f;
1511 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1512 {
1513 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1514 {
1515 return RectPosition.Center;
1516 }
1517 if (!flag)
1518 {
1519 return RectPosition.BottomCenter;
1520 }
1521 return RectPosition.TopCenter;
1522 }
1523 if (position.x < (float)width * 0.5f)
1524 {
1525 if (!flag)
1526 {
1527 return RectPosition.BottomLEFT;
1528 }
1529 return RectPosition.TopLEFT;
1530 }
1531 if (!flag)
1532 {
1533 return RectPosition.BottomRIGHT;
1534 }
1535 return RectPosition.TopRIGHT;
1536 }

◆ GetBit()

static bool ClassExtension.GetBit ( this byte  pByte,
int  bitNo 
)
inlinestatic

Definition at line 70 of file ClassExtension.cs.

71 {
72 return (pByte & (1 << bitNo)) != 0;
73 }

◆ GetComponentInChildrenExcludSelf< T >()

static T ClassExtension.GetComponentInChildrenExcludSelf< T > ( this Transform  c)
inlinestatic
Type Constraints
T :Component 

Definition at line 1330 of file ClassExtension.cs.

1330 : Component
1331 {
1332 for (int i = 0; i < c.childCount; i++)
1333 {
1334 T component = c.GetChild(i).GetComponent<T>();
1335 if ((bool)component)
1336 {
1337 return component;
1338 }
1339 }
1340 return null;
1341 }

◆ GetComponentInDirectChildren< T >()

static T ClassExtension.GetComponentInDirectChildren< T > ( this Component  comp)
inlinestatic
Type Constraints
T :Component 

Definition at line 1373 of file ClassExtension.cs.

1373 : Component
1374 {
1375 Transform transform = comp.transform;
1376 for (int i = 0; i < transform.childCount; i++)
1377 {
1378 T component = transform.GetChild(i).GetComponent<T>();
1379 if ((bool)component)
1380 {
1381 return component;
1382 }
1383 }
1384 return null;
1385 }

◆ GetComponentsInDirectChildren< T >() [1/2]

static List< T > ClassExtension.GetComponentsInDirectChildren< T > ( this Component  comp,
bool  includeInactive = true 
)
inlinestatic
Type Constraints
T :Component 

Definition at line 1358 of file ClassExtension.cs.

1358 : Component
1359 {
1360 List<T> list = new List<T>();
1361 Transform transform = comp.transform;
1362 for (int i = 0; i < transform.childCount; i++)
1363 {
1364 T component = transform.GetChild(i).GetComponent<T>();
1365 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1366 {
1367 list.Add(component);
1368 }
1369 }
1370 return list;
1371 }

◆ GetComponentsInDirectChildren< T >() [2/2]

static List< T > ClassExtension.GetComponentsInDirectChildren< T > ( this Transform  comp,
bool  includeInactive = true 
)
inlinestatic
Type Constraints
T :Component 

Definition at line 1343 of file ClassExtension.cs.

1343 : Component
1344 {
1345 List<T> list = new List<T>();
1346 Transform transform = comp.transform;
1347 for (int i = 0; i < transform.childCount; i++)
1348 {
1349 T component = transform.GetChild(i).GetComponent<T>();
1350 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1351 {
1352 list.Add(component);
1353 }
1354 }
1355 return list;
1356 }

◆ GetField< T >()

static T ClassExtension.GetField< T > ( this object  o,
string  name 
)
inlinestatic

Definition at line 223 of file ClassExtension.cs.

224 {
225 return (T)o.GetType().GetField(name).GetValue(o);
226 }

◆ GetForwardDiffPoint()

static float ClassExtension.GetForwardDiffPoint ( Vector2  forward)
inlinestaticprivate

Definition at line 1557 of file ClassExtension.cs.

1558 {
1559 if (object.Equals(forward, Vector2.up))
1560 {
1561 return 90f;
1562 }
1563 object.Equals(forward, Vector2.right);
1564 return 0f;
1565 }

References forward.

Referenced by LookAt2D().

◆ GetFullFileNameWithoutExtension() [1/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this FileInfo  fileInfo)
inlinestatic

Definition at line 887 of file ClassExtension.cs.

888 {
889 return fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name);
890 }

◆ GetFullFileNameWithoutExtension() [2/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this string  path)
inlinestatic

Definition at line 892 of file ClassExtension.cs.

893 {
894 return new FileInfo(path).GetFullFileNameWithoutExtension();
895 }

◆ GetLastChild()

static Transform ClassExtension.GetLastChild ( this Transform  trans)
inlinestatic

Definition at line 1538 of file ClassExtension.cs.

1539 {
1540 return trans.GetChild(trans.childCount - 1);
1541 }

◆ GetList< T >()

static List< T > ClassExtension.GetList< T > ( this IDictionary  source)
inlinestatic

Definition at line 591 of file ClassExtension.cs.

592 {
593 List<T> list = new List<T>();
594 foreach (object value in source.Values)
595 {
596 if (value is T)
597 {
598 list.Add((T)value);
599 }
600 }
601 return list;
602 }

◆ GetOrCreate< T >()

static T ClassExtension.GetOrCreate< T > ( this Component  t)
inlinestatic
Type Constraints
T :Component 

Definition at line 1177 of file ClassExtension.cs.

1177 : Component
1178 {
1179 T val = t.gameObject.GetComponent<T>();
1180 if (!val)
1181 {
1182 val = t.gameObject.AddComponent<T>();
1183 }
1184 return val;
1185 }

◆ GetOrCreate< TKey, TValue >()

static TValue ClassExtension.GetOrCreate< TKey, TValue > ( this IDictionary< TKey, TValue >  dict,
TKey  key,
Func< TValue >  func = null 
)
inlinestatic

Definition at line 377 of file ClassExtension.cs.

378 {
379 TValue val = dict.TryGetValue(key);
380 if (val == null)
381 {
382 val = ((func != null) ? func() : Activator.CreateInstance<TValue>());
383 dict.Add(key, val);
384 }
385 return val;
386 }

◆ GetProperty< T >()

static T ClassExtension.GetProperty< T > ( this object  o,
string  name 
)
inlinestatic

Definition at line 233 of file ClassExtension.cs.

234 {
235 return (T)o.GetType().GetProperty(name).GetValue(o);
236 }

◆ GetRuntimeEventCount()

static int ClassExtension.GetRuntimeEventCount ( this UnityEventBase  unityEvent)
inlinestatic

Definition at line 1913 of file ClassExtension.cs.

1914 {
1915 Type typeFromHandle = typeof(UnityEventBase);
1916 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
1917 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
1918 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
1919 Type type3 = typeof(List<>).MakeGenericType(type2);
1920 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
1921 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
1922 object value = field.GetValue(unityEvent);
1923 object value2 = field2.GetValue(value);
1924 return (int)type3.GetProperty("Count").GetValue(value2, null);
1925 }

◆ GetSelectable()

static Selectable ClassExtension.GetSelectable ( this GameObject  go)
inlinestatic

Definition at line 1223 of file ClassExtension.cs.

1224 {
1225 return go.GetComponentInChildren<Selectable>();
1226 }

◆ HasField< T >()

static bool ClassExtension.HasField< T > ( this object  o,
string  name 
)
inlinestatic

Definition at line 213 of file ClassExtension.cs.

214 {
215 FieldInfo field = o.GetType().GetField(name);
216 if (field != null)
217 {
218 return typeof(T).IsAssignableFrom(field.FieldType);
219 }
220 return false;
221 }

◆ IndexOf()

static int ClassExtension.IndexOf ( this IList< Component >  list,
GameObject  go 
)
inlinestatic

Definition at line 297 of file ClassExtension.cs.

298 {
299 if (!go)
300 {
301 return -1;
302 }
303 for (int i = 0; i < list.Count; i++)
304 {
305 if (list[i].gameObject == go)
306 {
307 return i;
308 }
309 }
310 return -1;
311 }

◆ Instantiate< T >()

static T ClassExtension.Instantiate< T > ( this T  s)
inlinestatic
Type Constraints
T :ScriptableObject 

Definition at line 1905 of file ClassExtension.cs.

1905 : ScriptableObject
1906 {
1907 string name = s.name;
1908 T val = UnityEngine.Object.Instantiate(s);
1909 val.name = name;
1910 return val;
1911 }

◆ IsChildOf()

static bool ClassExtension.IsChildOf ( this GameObject  c,
GameObject  root 
)
inlinestatic

Definition at line 1247 of file ClassExtension.cs.

1248 {
1249 if (c.transform == root.transform)
1250 {
1251 return true;
1252 }
1253 if ((bool)c.transform.parent)
1254 {
1255 return c.transform.parent.gameObject.IsChildOf(root);
1256 }
1257 return false;
1258 }

◆ IsEmpty() [1/3]

static bool ClassExtension.IsEmpty ( this Array  array)
inlinestatic

Definition at line 288 of file ClassExtension.cs.

289 {
290 if (array != null)
291 {
292 return array.Length == 0;
293 }
294 return true;
295 }

◆ IsEmpty() [2/3]

static bool ClassExtension.IsEmpty ( this string  str)
inlinestatic

Definition at line 749 of file ClassExtension.cs.

750 {
751 if (str != null)
752 {
753 return str == "";
754 }
755 return true;
756 }

◆ IsEmpty() [3/3]

static string ClassExtension.IsEmpty ( this string  str,
string  defaultStr 
)
inlinestatic

Definition at line 758 of file ClassExtension.cs.

759 {
760 if (str != null && !(str == ""))
761 {
762 return str;
763 }
764 return defaultStr;
765 }

◆ IsInteractable()

static bool ClassExtension.IsInteractable ( this GameObject  obj)
inlinestatic

Definition at line 1237 of file ClassExtension.cs.

1238 {
1239 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1240 if ((bool)selectable)
1241 {
1242 return selectable.interactable;
1243 }
1244 return false;
1245 }

◆ IsMouseOver()

static bool ClassExtension.IsMouseOver ( this RectTransform  r,
Camera  cam 
)
inlinestatic

Definition at line 1404 of file ClassExtension.cs.

1405 {
1406 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1407 }

◆ IsNull()

static bool ClassExtension.IsNull ( this object  o)
inlinestatic

Definition at line 117 of file ClassExtension.cs.

118 {
119 return o == null;
120 }

◆ IsOn()

static bool ClassExtension.IsOn ( this int  data,
int  digit 
)
inlinestatic

Definition at line 122 of file ClassExtension.cs.

123 {
124 BitArray32 bitArray = default(BitArray32);
125 bitArray.SetInt(data);
126 return bitArray[digit];
127 }
void SetInt(int i)
Definition: BitArray32.cs:89

References BitArray32.SetInt().

◆ IsPrefab()

static bool ClassExtension.IsPrefab ( this Component  c)
inlinestatic

Definition at line 1260 of file ClassExtension.cs.

1261 {
1262 return c.gameObject.scene.name == null;
1263 }

◆ lang() [1/2]

static string ClassExtension.lang ( this string  s)
inlinestatic

Definition at line 19 of file ClassExtension.cs.

20 {
21 return Lang.Get(s);
22 }
static string Get(string id)
Definition: Lang.cs:91

References Lang.Get().

◆ lang() [2/2]

static string ClassExtension.lang ( this string  s,
string  ref1,
string  ref2 = null,
string  ref3 = null,
string  ref4 = null,
string  ref5 = null 
)
inlinestatic

Definition at line 30 of file ClassExtension.cs.

31 {
32 return Lang.Parse(s, ref1, ref2, ref3, ref4, ref5);
33 }
static string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null, string val5=null)
Definition: Lang.cs:147

References Lang.Parse().

◆ langGame() [1/2]

static string ClassExtension.langGame ( this string  s)
inlinestatic

Definition at line 35 of file ClassExtension.cs.

36 {
37 return Lang.Game.Get(s);
38 }
static LangGame Game
Definition: Lang.cs:48
string Get(string id)
Definition: SourceLang.cs:12

References Lang.Game, and SourceLang< T >.Get().

◆ langGame() [2/2]

static string ClassExtension.langGame ( this string  s,
string  ref1,
string  ref2 = null,
string  ref3 = null,
string  ref4 = null 
)
inlinestatic

Definition at line 40 of file ClassExtension.cs.

41 {
42 return Lang.Game.Parse(s, ref1, ref2, ref3, ref4);
43 }
string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null)
Definition: SourceLang.cs:43

References Lang.Game, and SourceLang< T >.Parse().

◆ langPlural()

static string ClassExtension.langPlural ( this string  s,
int  i 
)
inlinestatic

Definition at line 24 of file ClassExtension.cs.

25 {
26 string text = Lang.Get(s);
27 return Lang.Parse((i <= 1 || !Lang.setting.pluralize) ? text : pluralizer.Pluralize(text), i.ToString() ?? "");
28 }

References Lang.Get(), Lang.Parse(), LangSetting.pluralize, pluralizer, and Lang.setting.

◆ LastItem< TValue >()

static TValue ClassExtension.LastItem< TValue > ( this IList< TValue >  source)
inlinestatic

Definition at line 513 of file ClassExtension.cs.

514 {
515 if (source.Count != 0)
516 {
517 return source[source.Count - 1];
518 }
519 return default(TValue);
520 }

◆ LookAt2D() [1/2]

static void ClassExtension.LookAt2D ( this Transform  self,
Transform  target,
Vector2  forward 
)
inlinestatic

Definition at line 1567 of file ClassExtension.cs.

1568 {
1569 self.LookAt2D(target.position, forward);
1570 }

References forward.

◆ LookAt2D() [2/2]

static void ClassExtension.LookAt2D ( this Transform  self,
Vector3  target,
Vector2  forward 
)
inlinestatic

Definition at line 1572 of file ClassExtension.cs.

1573 {
1574 float forwardDiffPoint = GetForwardDiffPoint(forward);
1575 Vector3 vector = target - self.position;
1576 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1577 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1578 }
static float GetForwardDiffPoint(Vector2 forward)

References forward, and GetForwardDiffPoint().

◆ LoopSelectable() [1/2]

static void ClassExtension.LoopSelectable ( this List< Selectable >  sels,
bool  vertical = true,
bool  horizonal = true,
bool  asGroup = true 
)
inlinestatic

Definition at line 1003 of file ClassExtension.cs.

1004 {
1005 for (int i = 0; i < sels.Count; i++)
1006 {
1007 Selectable selectable = sels[i];
1008 Selectable selectable2 = sels[0];
1009 Navigation navigation = selectable.navigation;
1010 if (horizonal)
1011 {
1012 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1013 }
1014 if (asGroup)
1015 {
1016 for (int j = i + 1; j < sels.Count; j++)
1017 {
1018 if (sels[j].transform.position.y < selectable.transform.position.y)
1019 {
1020 selectable2 = sels[j];
1021 break;
1022 }
1023 }
1024 }
1025 else
1026 {
1027 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1028 }
1029 if (vertical)
1030 {
1031 navigation.selectOnDown = selectable2;
1032 }
1033 selectable.navigation = navigation;
1034 }
1035 for (int num = sels.Count - 1; num >= 0; num--)
1036 {
1037 Selectable selectable3 = sels[num];
1038 Selectable selectable4 = sels[sels.Count - 1];
1039 Navigation navigation2 = selectable3.navigation;
1040 if (horizonal)
1041 {
1042 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1043 }
1044 if (asGroup)
1045 {
1046 int num2 = sels.Count - 1;
1047 for (int num3 = num - 1; num3 >= 0; num3--)
1048 {
1049 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1050 {
1051 num2 = num3;
1052 break;
1053 }
1054 }
1055 int num4 = num2;
1056 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1057 {
1058 selectable4 = sels[num4];
1059 num4--;
1060 }
1061 }
1062 else
1063 {
1064 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1065 }
1066 if (vertical)
1067 {
1068 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1069 }
1070 navigation2.mode = Navigation.Mode.Explicit;
1071 selectable3.navigation = navigation2;
1072 }
1073 }

◆ LoopSelectable() [2/2]

static void ClassExtension.LoopSelectable ( this Transform  l,
bool  vertical = true,
bool  horizonal = true,
bool  asGroup = true 
)
inlinestatic

Definition at line 1075 of file ClassExtension.cs.

1076 {
1077 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1078 for (int num = list.Count - 1; num >= 0; num--)
1079 {
1080 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1081 {
1082 list.RemoveAt(num);
1083 }
1084 }
1085 list.LoopSelectable(vertical, horizonal, asGroup);
1086 }

◆ LoopTail< T >()

static void ClassExtension.LoopTail< T > ( this List< T >  list,
bool  vertical = false 
)
inlinestatic
Type Constraints
T :Selectable 

Definition at line 955 of file ClassExtension.cs.

955 : Selectable
956 {
957 if (list.Count > 1)
958 {
959 Navigation navigation = list[0].navigation;
960 Navigation navigation2 = list[list.Count - 1].navigation;
961 if (vertical)
962 {
963 navigation.selectOnUp = list[list.Count - 1];
964 navigation2.selectOnDown = list[0];
965 }
966 else
967 {
968 navigation.selectOnLeft = list[list.Count - 1];
969 navigation2.selectOnRight = list[0];
970 }
971 list[0].navigation = navigation;
972 list[list.Count - 1].navigation = navigation2;
973 }
974 }

◆ Minimum()

static int ClassExtension.Minimum ( this int  i)
inlinestatic

Definition at line 104 of file ClassExtension.cs.

105 {
106 if (i != 0)
107 {
108 if (i <= 0)
109 {
110 return -1;
111 }
112 return 1;
113 }
114 return 0;
115 }

◆ Move< TValue >()

static TValue ClassExtension.Move< TValue > ( this IList< TValue >  list,
TValue  target,
int  a 
)
inlinestatic

Definition at line 313 of file ClassExtension.cs.

314 {
315 int num = list.IndexOf(target);
316 int num2 = num + a;
317 if (num2 < 0)
318 {
319 num2 = list.Count - 1;
320 }
321 if (num2 >= list.Count)
322 {
323 num2 = 0;
324 }
325 list.Remove(target);
326 list.Insert(num2, target);
327 return list[num];
328 }

◆ Multiply()

static Color ClassExtension.Multiply ( this Color  c,
float  mtp,
float  add 
)
inlinestatic

Definition at line 1111 of file ClassExtension.cs.

1112 {
1113 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1114 }

References Color.

◆ NextEnum< T >()

static T ClassExtension.NextEnum< T > ( this T  src)
inlinestatic
Type Constraints
T :struct 

Definition at line 149 of file ClassExtension.cs.

149 : struct
150 {
151 return ((T[])Enum.GetValues(src.GetType())).NextItem(src);
152 }

◆ NextIndex< TValue >()

static int ClassExtension.NextIndex< TValue > ( this IList< TValue >  source,
TValue  val 
)
inlinestatic

Definition at line 536 of file ClassExtension.cs.

537 {
538 if (val == null)
539 {
540 return 0;
541 }
542 int num = source.IndexOf(val) + 1;
543 if (num >= source.Count)
544 {
545 num = 0;
546 }
547 return num;
548 }

◆ NextItem< TValue >() [1/2]

static TValue ClassExtension.NextItem< TValue > ( this IList< TValue >  source,
ref int  index 
)
inlinestatic

Definition at line 522 of file ClassExtension.cs.

523 {
524 index++;
525 if (index >= source.Count)
526 {
527 index = 0;
528 }
529 if (source.Count != 0)
530 {
531 return source[index];
532 }
533 return default(TValue);
534 }

◆ NextItem< TValue >() [2/2]

static TValue ClassExtension.NextItem< TValue > ( this IList< TValue >  source,
TValue  val 
)
inlinestatic

Definition at line 550 of file ClassExtension.cs.

551 {
552 int num = source.IndexOf(val) + 1;
553 if (num >= source.Count)
554 {
555 num = 0;
556 }
557 if (source.Count != 0)
558 {
559 return source[num];
560 }
561 return default(TValue);
562 }

◆ Parentheses()

static string ClassExtension.Parentheses ( this string  str)
inlinestatic

Definition at line 45 of file ClassExtension.cs.

46 {
47 return "(" + str + ")";
48 }

◆ Plus()

static Vector3 ClassExtension.Plus ( this Vector3  v,
Vector2  v2 
)
inlinestatic

Definition at line 1585 of file ClassExtension.cs.

1586 {
1587 v.x += v2.x;
1588 v.y += v2.y;
1589 return v;
1590 }

◆ PlusX()

static Vector3 ClassExtension.PlusX ( this Vector3  v,
float  a 
)
inlinestatic

Definition at line 1604 of file ClassExtension.cs.

1605 {
1606 v.x += a;
1607 return v;
1608 }

◆ PlusY()

static Vector3 ClassExtension.PlusY ( this Vector3  v,
float  a 
)
inlinestatic

Definition at line 1610 of file ClassExtension.cs.

1611 {
1612 v.y += a;
1613 return v;
1614 }

◆ PlusZ()

static Vector3 ClassExtension.PlusZ ( this Vector3  v,
float  a 
)
inlinestatic

Definition at line 1616 of file ClassExtension.cs.

1617 {
1618 v.z += a;
1619 return v;
1620 }

◆ PrevEnum< T >()

static T ClassExtension.PrevEnum< T > ( this T  src)
inlinestatic
Type Constraints
T :struct 

Definition at line 154 of file ClassExtension.cs.

154 : struct
155 {
156 return ((T[])Enum.GetValues(src.GetType())).PrevItem(src);
157 }

◆ PrevItem< TValue >()

static TValue ClassExtension.PrevItem< TValue > ( this IList< TValue >  source,
TValue  val 
)
inlinestatic

Definition at line 564 of file ClassExtension.cs.

565 {
566 int num = source.IndexOf(val) - 1;
567 if (num < 0)
568 {
569 num = source.Count - 1;
570 }
571 if (source.Count != 0)
572 {
573 return source[num];
574 }
575 return default(TValue);
576 }

◆ Random()

static Vector3 ClassExtension.Random ( this Vector3  v)
inlinestatic

Definition at line 1900 of file ClassExtension.cs.

1901 {
1902 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
1903 }
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:42

References Rand.Range().

◆ RandomItem< T >()

static T ClassExtension.RandomItem< T > ( this IEnumerable< T >  ie)
inlinestatic

Definition at line 402 of file ClassExtension.cs.

403 {
404 int num = ie.Count();
405 if (num == 0)
406 {
407 return default(T);
408 }
409 return ie.ElementAt(Rand.rnd(num));
410 }
static int rnd(int max)
Definition: Rand.cs:52

References Rand.rnd().

◆ RandomItem< TKey, TValue >()

static TValue ClassExtension.RandomItem< TKey, TValue > ( this IDictionary< TKey, TValue >  source)
inlinestatic

Definition at line 412 of file ClassExtension.cs.

413 {
414 if (source.Count != 0)
415 {
416 return source.ElementAt(Rand.rnd(source.Count)).Value;
417 }
418 return default(TValue);
419 }

References Rand.rnd().

◆ RandomItem< TValue >() [1/4]

static TValue ClassExtension.RandomItem< TValue > ( this IList< TValue >  source)
inlinestatic

Definition at line 421 of file ClassExtension.cs.

422 {
423 if (source.Count != 0)
424 {
425 return source[Rand.rnd(source.Count)];
426 }
427 return default(TValue);
428 }

References Rand.rnd().

◆ RandomItem< TValue >() [2/4]

static TValue ClassExtension.RandomItem< TValue > ( this IList< TValue >  source,
Func< TValue, bool >  funcValid,
TValue  defaultValue = default(TValue) 
)
inlinestatic

Definition at line 454 of file ClassExtension.cs.

455 {
456 for (int i = 0; i < 100; i++)
457 {
458 TValue val = source[Rand.rnd(source.Count)];
459 if (funcValid(val))
460 {
461 return val;
462 }
463 }
464 return defaultValue;
465 }

References Rand.rnd().

◆ RandomItem< TValue >() [3/4]

static TValue ClassExtension.RandomItem< TValue > ( this IList< TValue >  source,
int  exclude 
)
inlinestatic

Definition at line 435 of file ClassExtension.cs.

436 {
437 if (source.Count > 1)
438 {
439 int num;
440 do
441 {
442 num = Rand.rnd(source.Count);
443 }
444 while (num == exclude);
445 return source[num];
446 }
447 if (source.Count == 1)
448 {
449 return source[0];
450 }
451 return default(TValue);
452 }

References Rand.rnd().

◆ RandomItem< TValue >() [4/4]

static TValue ClassExtension.RandomItem< TValue > ( this IList< TValue >  source,
TValue  exclude 
)
inlinestatic

Definition at line 430 of file ClassExtension.cs.

431 {
432 return source.RandomItem(source.IndexOf(exclude));
433 }

◆ RandomItemWeighted< TValue >()

static TValue ClassExtension.RandomItemWeighted< TValue > ( this IList< TValue >  source,
Func< TValue, float >  getWeight 
)
inlinestatic

Definition at line 467 of file ClassExtension.cs.

468 {
469 if (source.Count == 0)
470 {
471 return default(TValue);
472 }
473 if (source.Count == 1)
474 {
475 return source[0];
476 }
477 float num = 0f;
478 foreach (TValue item in source)
479 {
480 num += getWeight(item);
481 }
482 float num2 = Rand.Range(0f, num);
483 num = 0f;
484 foreach (TValue item2 in source)
485 {
486 num += getWeight(item2);
487 if (num2 < num)
488 {
489 return item2;
490 }
491 }
492 return source.First();
493 }

References item, and Rand.Range().

◆ RebuildLayout()

static void ClassExtension.RebuildLayout ( this Component  c,
bool  recursive = false 
)
inlinestatic

Definition at line 1409 of file ClassExtension.cs.

1410 {
1411 if (recursive)
1412 {
1413 foreach (Transform item in c.transform)
1414 {
1415 if (item is RectTransform)
1416 {
1417 item.RebuildLayout(recursive: true);
1418 }
1419 }
1420 }
1421 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1422 }

References item.

◆ RebuildLayoutTo()

static void ClassExtension.RebuildLayoutTo ( this Component  c,
Component  target 
)
inlinestatic

Definition at line 1433 of file ClassExtension.cs.

1434 {
1435 c.RebuildLayout();
1436 if (!(c == target) && (bool)c.transform.parent)
1437 {
1438 c.transform.parent.RebuildLayoutTo(target);
1439 }
1440 }

◆ RebuildLayoutTo< T >()

static void ClassExtension.RebuildLayoutTo< T > ( this Component  c)
inlinestatic
Type Constraints
T :Component 

Definition at line 1424 of file ClassExtension.cs.

1424 : Component
1425 {
1426 c.RebuildLayout();
1427 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1428 {
1429 c.transform.parent.RebuildLayoutTo<T>();
1430 }
1431 }

◆ Rect()

static RectTransform ClassExtension.Rect ( this Component  c)
inlinestatic

Definition at line 1187 of file ClassExtension.cs.

1188 {
1189 return c.transform as RectTransform;
1190 }

◆ Remainder< TValue >()

static TValue ClassExtension.Remainder< TValue > ( this IList< TValue >  source,
int  divider 
)
inlinestatic

Definition at line 495 of file ClassExtension.cs.

496 {
497 if (source.Count != 0)
498 {
499 return source[divider % source.Count];
500 }
501 return default(TValue);
502 }

◆ Repeat()

static string ClassExtension.Repeat ( this string  str,
int  count 
)
inlinestatic

Definition at line 723 of file ClassExtension.cs.

724 {
725 StringBuilder stringBuilder = new StringBuilder();
726 for (int i = 0; i < Mathf.Abs(count); i++)
727 {
728 stringBuilder.Append(str);
729 }
730 return stringBuilder.ToString();
731 }

◆ Set< T1, T2 >()

static void ClassExtension.Set< T1, T2 > ( this Dictionary< T1, T2 >  dic,
Dictionary< T1, T2 >  from 
)
inlinestatic

Definition at line 629 of file ClassExtension.cs.

630 {
631 dic.Clear();
632 foreach (KeyValuePair<T1, T2> item in from)
633 {
634 dic[item.Key] = item.Value;
635 }
636 }

References item.

◆ SetActive() [1/2]

static void ClassExtension.SetActive ( this Component  c,
bool  enable 
)
inlinestatic

Definition at line 1206 of file ClassExtension.cs.

1207 {
1208 if (c.gameObject.activeSelf != enable)
1209 {
1210 c.gameObject.SetActive(enable);
1211 }
1212 }

Referenced by ContentQuest.RefreshTrackButtons().

◆ SetActive() [2/2]

static void ClassExtension.SetActive ( this Component  c,
bool  enable,
Action< bool >  onChangeState 
)
inlinestatic

Definition at line 1214 of file ClassExtension.cs.

1215 {
1216 if (c.gameObject.activeSelf != enable)
1217 {
1218 c.gameObject.SetActive(enable);
1219 onChangeState(enable);
1220 }
1221 }

◆ SetAlpha() [1/4]

static Color ClassExtension.SetAlpha ( this Color  c,
float  a 
)
inlinestatic

Definition at line 1105 of file ClassExtension.cs.

1106 {
1107 c.a = a;
1108 return c;
1109 }

◆ SetAlpha() [2/4]

static void ClassExtension.SetAlpha ( this Image  c,
float  a 
)
inlinestatic

Definition at line 1095 of file ClassExtension.cs.

1096 {
1097 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1098 }

References Color.

◆ SetAlpha() [3/4]

static void ClassExtension.SetAlpha ( this RawImage  c,
float  a 
)
inlinestatic

Definition at line 1100 of file ClassExtension.cs.

1101 {
1102 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1103 }

References Color.

◆ SetAlpha() [4/4]

static void ClassExtension.SetAlpha ( this Text  text,
float  aloha = 1f 
)
inlinestatic

Definition at line 1144 of file ClassExtension.cs.

1145 {
1146 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1147 }

References Color.

◆ SetAnchor() [1/2]

static void ClassExtension.SetAnchor ( this RectTransform  _rect,
RectPosition  anchor = RectPosition::Auto 
)
inlinestatic

Definition at line 1498 of file ClassExtension.cs.

1499 {
1500 Vector3 position = _rect.position;
1501 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1502 _rect.position = position;
1503 }

◆ SetAnchor() [2/2]

static void ClassExtension.SetAnchor ( this RectTransform  r,
float  minX,
float  minY,
float  maxX,
float  maxY 
)
inlinestatic

Definition at line 1458 of file ClassExtension.cs.

1459 {
1460 r.anchorMin = new Vector2(minX, minY);
1461 r.anchorMax = new Vector2(maxX, maxY);
1462 }

◆ SetBit()

static byte ClassExtension.SetBit ( this byte  pByte,
int  bitNo,
bool  value 
)
inlinestatic

Definition at line 75 of file ClassExtension.cs.

76 {
77 if (!value)
78 {
79 return Convert.ToByte(pByte & ~(1 << bitNo));
80 }
81 return Convert.ToByte(pByte | (1 << bitNo));
82 }

◆ SetEulerAngles()

static void ClassExtension.SetEulerAngles ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1766 of file ClassExtension.cs.

1767 {
1768 vector3.Set(x, y, z);
1769 transform.eulerAngles = vector3;
1770 }

References vector3.

◆ SetEulerAnglesX()

static void ClassExtension.SetEulerAnglesX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1772 of file ClassExtension.cs.

1773 {
1774 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1775 transform.eulerAngles = vector3;
1776 }

References vector3.

◆ SetEulerAnglesY()

static void ClassExtension.SetEulerAnglesY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1778 of file ClassExtension.cs.

1779 {
1780 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1781 transform.eulerAngles = vector3;
1782 }

References vector3.

◆ SetEulerAnglesZ()

static void ClassExtension.SetEulerAnglesZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1784 of file ClassExtension.cs.

1785 {
1786 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
1787 transform.eulerAngles = vector3;
1788 }

References vector3.

◆ SetField< T >()

static void ClassExtension.SetField< T > ( this object  o,
string  name,
value 
)
inlinestatic

Definition at line 228 of file ClassExtension.cs.

229 {
230 o.GetType().GetField(name).SetValue(o, value);
231 }

◆ SetLayerRecursively()

static void ClassExtension.SetLayerRecursively ( this GameObject  obj,
int  layer 
)
inlinestatic

Definition at line 1228 of file ClassExtension.cs.

1229 {
1230 obj.layer = layer;
1231 foreach (Transform item in obj.transform)
1232 {
1233 item.gameObject.SetLayerRecursively(layer);
1234 }
1235 }

References item.

◆ SetListener()

static void ClassExtension.SetListener ( this Button::ButtonClickedEvent  e,
Action  action 
)
inlinestatic

Definition at line 1135 of file ClassExtension.cs.

1136 {
1137 e.RemoveAllListeners();
1138 e.AddListener(delegate
1139 {
1140 action();
1141 });
1142 }

References Button.

◆ SetLocalEulerAngles()

static void ClassExtension.SetLocalEulerAngles ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1814 of file ClassExtension.cs.

1815 {
1816 vector3.Set(x, y, z);
1817 transform.localEulerAngles = vector3;
1818 }

References vector3.

◆ SetLocalEulerAnglesX()

static void ClassExtension.SetLocalEulerAnglesX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1820 of file ClassExtension.cs.

1821 {
1822 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1823 transform.localEulerAngles = vector3;
1824 }

References vector3.

◆ SetLocalEulerAnglesY()

static void ClassExtension.SetLocalEulerAnglesY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1826 of file ClassExtension.cs.

1827 {
1828 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1829 transform.localEulerAngles = vector3;
1830 }

References vector3.

◆ SetLocalEulerAnglesZ()

static void ClassExtension.SetLocalEulerAnglesZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1832 of file ClassExtension.cs.

1833 {
1834 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
1835 transform.localEulerAngles = vector3;
1836 }

References vector3.

◆ SetLocalPosition()

static void ClassExtension.SetLocalPosition ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1670 of file ClassExtension.cs.

1671 {
1672 vector3.Set(x, y, z);
1673 transform.localPosition = vector3;
1674 }

References vector3.

◆ SetLocalPositionX()

static void ClassExtension.SetLocalPositionX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1676 of file ClassExtension.cs.

1677 {
1678 vector3.Set(x, transform.localPosition.y, transform.localPosition.z);
1679 transform.localPosition = vector3;
1680 }

References vector3.

◆ SetLocalPositionY()

static void ClassExtension.SetLocalPositionY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1682 of file ClassExtension.cs.

1683 {
1684 vector3.Set(transform.localPosition.x, y, transform.localPosition.z);
1685 transform.localPosition = vector3;
1686 }

References vector3.

◆ SetLocalPositionZ()

static void ClassExtension.SetLocalPositionZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1688 of file ClassExtension.cs.

1689 {
1690 vector3.Set(transform.localPosition.x, transform.localPosition.y, z);
1691 transform.localPosition = vector3;
1692 }

References vector3.

◆ SetLocalScale()

static void ClassExtension.SetLocalScale ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1718 of file ClassExtension.cs.

1719 {
1720 vector3.Set(x, y, z);
1721 transform.localScale = vector3;
1722 }

References vector3.

◆ SetLocalScaleX()

static void ClassExtension.SetLocalScaleX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1724 of file ClassExtension.cs.

1725 {
1726 vector3.Set(x, transform.localScale.y, transform.localScale.z);
1727 transform.localScale = vector3;
1728 }

References vector3.

◆ SetLocalScaleY()

static void ClassExtension.SetLocalScaleY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1730 of file ClassExtension.cs.

1731 {
1732 vector3.Set(transform.localScale.x, y, transform.localScale.z);
1733 transform.localScale = vector3;
1734 }

References vector3.

◆ SetLocalScaleZ()

static void ClassExtension.SetLocalScaleZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1736 of file ClassExtension.cs.

1737 {
1738 vector3.Set(transform.localScale.x, transform.localScale.y, z);
1739 transform.localScale = vector3;
1740 }

References vector3.

◆ SetNavigation()

static void ClassExtension.SetNavigation ( this Component  a,
Component  b,
bool  vertical = false 
)
inlinestatic

Definition at line 976 of file ClassExtension.cs.

977 {
978 if (!a || !b)
979 {
980 return;
981 }
982 Selectable component = a.GetComponent<Selectable>();
983 Selectable component2 = b.GetComponent<Selectable>();
984 if ((bool)component && (bool)component2)
985 {
986 Navigation navigation = component.navigation;
987 Navigation navigation2 = component2.navigation;
988 if (vertical)
989 {
990 navigation.selectOnUp = component2;
991 navigation2.selectOnDown = component;
992 }
993 else
994 {
995 navigation.selectOnLeft = component2;
996 navigation2.selectOnRight = component;
997 }
998 component.navigation = navigation;
999 component2.navigation = navigation2;
1000 }
1001 }

◆ SetOnClick()

static void ClassExtension.SetOnClick ( this Button  b,
Action  action 
)
inlinestatic

Definition at line 1126 of file ClassExtension.cs.

1127 {
1128 b.onClick.RemoveAllListeners();
1129 b.onClick.AddListener(delegate
1130 {
1131 action();
1132 });
1133 }

◆ SetPivot()

static void ClassExtension.SetPivot ( this RectTransform  r,
float  x,
float  y 
)
inlinestatic

Definition at line 1453 of file ClassExtension.cs.

1454 {
1455 r.pivot = new Vector2(x, y);
1456 }

◆ SetPosition()

static void ClassExtension.SetPosition ( this Transform  transform,
float  x,
float  y,
float  z 
)
inlinestatic

Definition at line 1622 of file ClassExtension.cs.

1623 {
1624 vector3.Set(x, y, z);
1625 transform.position = vector3;
1626 }

References vector3.

◆ SetPositionX()

static void ClassExtension.SetPositionX ( this Transform  transform,
float  x 
)
inlinestatic

Definition at line 1628 of file ClassExtension.cs.

1629 {
1630 vector3.Set(x, transform.position.y, transform.position.z);
1631 transform.position = vector3;
1632 }

References vector3.

◆ SetPositionY()

static void ClassExtension.SetPositionY ( this Transform  transform,
float  y 
)
inlinestatic

Definition at line 1634 of file ClassExtension.cs.

1635 {
1636 vector3.Set(transform.position.x, y, transform.position.z);
1637 transform.position = vector3;
1638 }

References vector3.

◆ SetPositionZ()

static void ClassExtension.SetPositionZ ( this Transform  transform,
float  z 
)
inlinestatic

Definition at line 1640 of file ClassExtension.cs.

1641 {
1642 vector3.Set(transform.position.x, transform.position.y, z);
1643 transform.position = vector3;
1644 }

References vector3.

◆ SetProperty< T >()

static void ClassExtension.SetProperty< T > ( this object  o,
string  name,
value 
)
inlinestatic

Definition at line 238 of file ClassExtension.cs.

239 {
240 o.GetType().GetProperty(name).SetValue(o, value);
241 }

◆ SetRect()

static void ClassExtension.SetRect ( this RectTransform  r,
float  x,
float  y,
float  w,
float  h,
float  pivotX,
float  pivotY,
float  minX,
float  minY,
float  maxX,
float  maxY 
)
inlinestatic

Definition at line 1442 of file ClassExtension.cs.

1443 {
1444 r.SetPivot(pivotX, pivotY);
1445 r.SetAnchor(minX, minY, maxX, maxY);
1446 if (w != -1f)
1447 {
1448 r.sizeDelta = new Vector2(w, h);
1449 }
1450 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1451 }

◆ SetScale()

static void ClassExtension.SetScale ( this SpriteRenderer  renderer,
float  size 
)
inlinestatic

Definition at line 1548 of file ClassExtension.cs.

1549 {
1550 float x = renderer.bounds.size.x;
1551 float y = renderer.bounds.size.y;
1552 float x2 = size / x;
1553 float y2 = size / y;
1554 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1555 }

◆ SetSlider() [1/2]

static void ClassExtension.SetSlider ( this Slider  slider,
float  value,
Func< float, string >  action,
bool  notify 
)
inlinestatic

Definition at line 1149 of file ClassExtension.cs.

1150 {
1151 slider.SetSlider(value, action, -1, -1, notify);
1152 }

◆ SetSlider() [2/2]

static void ClassExtension.SetSlider ( this Slider  slider,
float  value,
Func< float, string >  action,
int  min = -1,
int  max = -1,
bool  notify = true 
)
inlinestatic

Definition at line 1154 of file ClassExtension.cs.

1155 {
1156 slider.onValueChanged.RemoveAllListeners();
1157 slider.onValueChanged.AddListener(delegate(float a)
1158 {
1159 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1160 });
1161 if (min != -1)
1162 {
1163 slider.minValue = min;
1164 slider.maxValue = max;
1165 }
1166 if (notify)
1167 {
1168 slider.value = value;
1169 }
1170 else
1171 {
1172 slider.SetValueWithoutNotify(value);
1173 }
1174 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1175 }

◆ SetY()

static Vector3 ClassExtension.SetY ( this Vector3  v,
float  a 
)
inlinestatic

Definition at line 1598 of file ClassExtension.cs.

1599 {
1600 v.y = a;
1601 return v;
1602 }

◆ SetZ()

static Vector3 ClassExtension.SetZ ( this Vector3  v,
float  a 
)
inlinestatic

Definition at line 1592 of file ClassExtension.cs.

1593 {
1594 v.z = a;
1595 return v;
1596 }

◆ Shuffle< TValue >()

static IList< TValue > ClassExtension.Shuffle< TValue > ( this IList< TValue >  list)
inlinestatic

Definition at line 343 of file ClassExtension.cs.

344 {
345 int num = list.Count;
346 while (num > 1)
347 {
348 int index = Rand._random.Next(num);
349 num--;
350 TValue value = list[num];
351 list[num] = list[index];
352 list[index] = value;
353 }
354 return list;
355 }
static Random _random
Definition: Rand.cs:7

References Rand._random.

◆ Sort< T >()

static void ClassExtension.Sort< T > ( this IList< T >  list,
Comparison< T >  comparison 
)
inlinestatic

Definition at line 243 of file ClassExtension.cs.

244 {
245 if (list is List<T>)
246 {
247 ((List<T>)list).Sort(comparison);
248 return;
249 }
250 List<T> list2 = new List<T>(list);
251 list2.Sort(comparison);
252 for (int i = 0; i < list.Count; i++)
253 {
254 list[i] = list2[i];
255 }
256 }

◆ SplitNewline()

static string[] ClassExtension.SplitNewline ( this string  str)
inlinestatic

Definition at line 787 of file ClassExtension.cs.

788 {
789 return str.Split(Environment.NewLine.ToCharArray());
790 }

◆ SplitToInts()

static int[] ClassExtension.SplitToInts ( this string  str,
char  separator 
)
inlinestatic

Definition at line 776 of file ClassExtension.cs.

777 {
778 string[] array = str.Split(separator);
779 int[] array2 = new int[array.Length];
780 for (int i = 0; i < array.Length; i++)
781 {
782 array2[i] = int.Parse(array[i]);
783 }
784 return array2;
785 }

◆ StripBrackets()

static string ClassExtension.StripBrackets ( this string  str)
inlinestatic

Definition at line 733 of file ClassExtension.cs.

734 {
735 return str.Replace("\"", "").Replace("「", "").Replace("」", "")
736 .Replace("“", "")
737 .Replace("\"", "");
738 }

◆ StripLastPun()

static string ClassExtension.StripLastPun ( this string  str)
inlinestatic

Definition at line 687 of file ClassExtension.cs.

688 {
689 if (str != null)
690 {
691 return str.TrimEnd(Lang.words.period);
692 }
693 return str;
694 }
char period
Definition: Lang.cs:19
static Words words
Definition: Lang.cs:26

References Lang.Words.period, and Lang.words.

◆ StripPun()

static string ClassExtension.StripPun ( this string  str,
bool  stripComma,
bool  insertSpaceForComma = false 
)
inlinestatic

Definition at line 696 of file ClassExtension.cs.

697 {
698 StringBuilder stringBuilder = new StringBuilder();
699 foreach (char c in str)
700 {
701 if (c == Lang.words.comma)
702 {
703 if (stripComma)
704 {
705 if (insertSpaceForComma)
706 {
707 stringBuilder.Append('\u3000');
708 }
709 }
710 else
711 {
712 stringBuilder.Append(c);
713 }
714 }
715 else if (c != Lang.words.period)
716 {
717 stringBuilder.Append(c);
718 }
719 }
720 return stringBuilder.ToString();
721 }
char comma
Definition: Lang.cs:17

References Lang.Words.comma, Lang.Words.period, and Lang.words.

◆ Tag()

static string ClassExtension.Tag ( this Color  c)
inlinestatic

Definition at line 1116 of file ClassExtension.cs.

1117 {
1118 return "<color=" + $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}" + ">";
1119 }

References $.

◆ TagColor() [1/2]

static string ClassExtension.TagColor ( this string  s,
Color  c 
)
inlinestatic

Definition at line 872 of file ClassExtension.cs.

873 {
874 return "<color=" + c.ToHex() + ">" + s + "</color>";
875 }

◆ TagColor() [2/2]

static string ClassExtension.TagColor ( this string  s,
Color  c,
string  txt 
)
inlinestatic

Definition at line 867 of file ClassExtension.cs.

868 {
869 return s + "<color=" + c.ToHex() + ">" + txt + "</color>";
870 }

◆ TagSize() [1/2]

static string ClassExtension.TagSize ( this string  s,
int  size 
)
inlinestatic

Definition at line 882 of file ClassExtension.cs.

883 {
884 return "<size=" + size + ">" + s + "</size>";
885 }

◆ TagSize() [2/2]

static string ClassExtension.TagSize ( this string  s,
string  txt,
int  size 
)
inlinestatic

Definition at line 877 of file ClassExtension.cs.

878 {
879 return s + "<size=" + size + ">" + txt + "</size>";
880 }

◆ ToBytes()

static byte[] ClassExtension.ToBytes ( this BitArray  bits)
inlinestatic

Definition at line 63 of file ClassExtension.cs.

64 {
65 byte[] array = new byte[(bits.Length - 1) / 8 + 1];
66 bits.CopyTo(array, 0);
67 return array;
68 }

◆ ToColor()

static Color ClassExtension.ToColor ( this string  s)
inlinestatic

Definition at line 1088 of file ClassExtension.cs.

1089 {
1090 Color color = Color.white;
1091 ColorUtility.TryParseHtmlString("#" + s, out color);
1092 return color;
1093 }

References Color.

◆ ToDictionary< T >()

static void ClassExtension.ToDictionary< T > ( this IList< UPair< T > >  list,
ref Dictionary< string, T >  dic 
)
inlinestatic

Definition at line 604 of file ClassExtension.cs.

605 {
606 dic = new Dictionary<string, T>();
607 for (int i = 0; i < list.Count; i++)
608 {
609 dic.Add(list[i].name, list[i].value);
610 }
611 }

◆ ToEnum< T >() [1/3]

static T ClassExtension.ToEnum< T > ( this int  value)
inlinestatic

Definition at line 129 of file ClassExtension.cs.

130 {
131 return (T)Enum.ToObject(typeof(T), value);
132 }

◆ ToEnum< T >() [2/3]

static T ClassExtension.ToEnum< T > ( this long  value)
inlinestatic

Definition at line 134 of file ClassExtension.cs.

135 {
136 return (T)Enum.ToObject(typeof(T), value);
137 }

◆ ToEnum< T >() [3/3]

static T ClassExtension.ToEnum< T > ( this string  value,
bool  ignoreCase = true 
)
inlinestatic

Definition at line 139 of file ClassExtension.cs.

140 {
141 return (T)Enum.Parse(typeof(T), value, ignoreCase);
142 }

◆ ToField< T >()

static T ClassExtension.ToField< T > ( this string  s,
object  o 
)
inlinestatic

Definition at line 208 of file ClassExtension.cs.

209 {
210 return (T)o.GetType().GetField(s).GetValue(o);
211 }

◆ ToFloat()

static float ClassExtension.ToFloat ( this string  str)
inlinestatic

Definition at line 668 of file ClassExtension.cs.

669 {
670 float result = 0f;
671 try
672 {
673 if (!float.TryParse(str, out result))
674 {
675 Debug.Log("exception: ToFlat1" + str);
676 result = 1f;
677 }
678 }
679 catch
680 {
681 Debug.Log("exception: ToFlat2" + str);
682 result = 1f;
683 }
684 return result;
685 }

References Debug.

◆ ToFormat() [1/2]

static string ClassExtension.ToFormat ( this int  a)
inlinestatic

Definition at line 835 of file ClassExtension.cs.

836 {
837 return $"{a:#,0}";
838 }

References $.

◆ ToFormat() [2/2]

static string ClassExtension.ToFormat ( this long  a)
inlinestatic

Definition at line 840 of file ClassExtension.cs.

841 {
842 return $"{a:#,0}";
843 }

References $.

◆ ToggleActive()

static void ClassExtension.ToggleActive ( this Component  c)
inlinestatic

Definition at line 1201 of file ClassExtension.cs.

1202 {
1203 c.SetActive(!c.gameObject.activeSelf);
1204 }

◆ ToggleKeyword()

static void ClassExtension.ToggleKeyword ( this Material  m,
string  id,
bool  enable 
)
inlinestatic

Definition at line 1862 of file ClassExtension.cs.

1863 {
1864 if (enable)
1865 {
1866 m.EnableKeyword(id);
1867 }
1868 else
1869 {
1870 m.DisableKeyword(id);
1871 }
1872 }

◆ ToHex()

static string ClassExtension.ToHex ( this Color  c)
inlinestatic

Definition at line 1121 of file ClassExtension.cs.

1122 {
1123 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1124 }

References $.

◆ ToInt() [1/2]

static int ClassExtension.ToInt ( this string  str)
inlinestatic

Definition at line 659 of file ClassExtension.cs.

660 {
661 if (int.TryParse(str, out var result))
662 {
663 return result;
664 }
665 return 0;
666 }

◆ ToInt() [2/2]

static int ClassExtension.ToInt ( this string  str,
Type  type 
)
inlinestatic

Definition at line 648 of file ClassExtension.cs.

649 {
650 FieldInfo field = type.GetField(str, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
651 if (field == null)
652 {
653 Debug.LogError("Field is null:" + str + "/" + type);
654 return -1;
655 }
656 return (int)field.GetValue(null);
657 }

References Debug.

◆ ToInt2()

static int ClassExtension.ToInt2 ( this float  a)
inlinestatic

Definition at line 94 of file ClassExtension.cs.

95 {
96 return (int)(a * 100f);
97 }

◆ ToInt3()

static int ClassExtension.ToInt3 ( this float  a)
inlinestatic

Definition at line 84 of file ClassExtension.cs.

85 {
86 return (int)(a * 1000f);
87 }

◆ ToInt< T >()

static int ClassExtension.ToInt< T > ( this string  str)
inlinestatic

Definition at line 643 of file ClassExtension.cs.

644 {
645 return str.ToInt(typeof(T));
646 }

◆ ToShortNumber()

static string ClassExtension.ToShortNumber ( this int  a)
inlinestatic

Definition at line 813 of file ClassExtension.cs.

814 {
815 string text;
816 if (a < 1000000)
817 {
818 if (a >= 1000)
819 {
820 return a / 1000 + "K";
821 }
822 text = a.ToString();
823 if (text == null)
824 {
825 return "";
826 }
827 }
828 else
829 {
830 text = a / 1000000 + "M";
831 }
832 return text;
833 }

◆ ToText()

static string ClassExtension.ToText ( this int  a,
bool  skipIfZero = true 
)
inlinestatic

Definition at line 845 of file ClassExtension.cs.

846 {
847 object obj;
848 if (!(a == 0 && skipIfZero))
849 {
850 if (a >= 0)
851 {
852 return "+" + a;
853 }
854 obj = a.ToString();
855 if (obj == null)
856 {
857 return "";
858 }
859 }
860 else
861 {
862 obj = "";
863 }
864 return (string)obj;
865 }

◆ ToTitleCase()

static string ClassExtension.ToTitleCase ( this string  s,
bool  wholeText = false 
)
inlinestatic

Definition at line 928 of file ClassExtension.cs.

929 {
931 {
932 return s;
933 }
934 char[] array = s.ToCharArray();
935 bool flag = true;
936 for (int i = 0; i < array.Length; i++)
937 {
938 if (flag)
939 {
940 array[i] = char.ToUpper(array[i]);
941 flag = false;
942 }
943 if (!wholeText)
944 {
945 break;
946 }
947 if (array[i] == ' ')
948 {
949 flag = true;
950 }
951 }
952 return new string(array);
953 }
bool capitalize
Definition: LangSetting.cs:34

References LangSetting.capitalize, and Lang.setting.

◆ ToType()

static Type ClassExtension.ToType ( this string  value)
inlinestatic

Definition at line 144 of file ClassExtension.cs.

145 {
146 return Type.GetType("Elona." + value + ", Assembly-CSharp");
147 }

◆ ToVector2()

static Vector2 ClassExtension.ToVector2 ( this Vector3  self)
inlinestatic

Definition at line 1543 of file ClassExtension.cs.

1544 {
1545 return new Vector2(self.x, self.z);
1546 }

◆ TrimNewLines()

static string ClassExtension.TrimNewLines ( this string  text)
inlinestatic

Definition at line 767 of file ClassExtension.cs.

768 {
769 while (text.EndsWith(Environment.NewLine))
770 {
771 text = text.Substring(0, text.Length - Environment.NewLine.Length);
772 }
773 return text;
774 }

◆ TryAddExtension()

static string ClassExtension.TryAddExtension ( this string  s,
string  ext 
)
inlinestatic

Definition at line 740 of file ClassExtension.cs.

741 {
742 if (!s.Contains("." + ext))
743 {
744 return s + "." + ext;
745 }
746 return s;
747 }

◆ TryGet< TValue >() [1/2]

static TValue ClassExtension.TryGet< TValue > ( this IList< TValue >  array,
int  index,
bool  returnNull 
)
inlinestatic

Definition at line 279 of file ClassExtension.cs.

280 {
281 if (index >= array.Count)
282 {
283 return default(TValue);
284 }
285 return array[index];
286 }

◆ TryGet< TValue >() [2/2]

static TValue ClassExtension.TryGet< TValue > ( this IList< TValue >  array,
int  index,
int  defIndex = -1 
)
inlinestatic

Definition at line 258 of file ClassExtension.cs.

259 {
260 if (array.Count != 0)
261 {
262 if (index >= array.Count)
263 {
264 if (defIndex != -1)
265 {
266 if (array.Count <= defIndex)
267 {
268 return array[Mathf.Max(0, array.Count - 1)];
269 }
270 return array[defIndex];
271 }
272 return array[Mathf.Max(0, array.Count - 1)];
273 }
274 return array[Math.Max(0, index)];
275 }
276 return default(TValue);
277 }

◆ TryGetValue< TKey, TValue >() [1/2]

static TValue ClassExtension.TryGetValue< TKey, TValue > ( this IDictionary< TKey, TValue >  source,
TKey  key,
TKey  key_fallback 
)
inlinestatic

Definition at line 367 of file ClassExtension.cs.

368 {
369 TValue value = default(TValue);
370 if (key != null && source.TryGetValue(key, out value))
371 {
372 return value;
373 }
374 return source[key_fallback];
375 }

◆ TryGetValue< TKey, TValue >() [2/2]

static TValue ClassExtension.TryGetValue< TKey, TValue > ( this IDictionary< TKey, TValue >  source,
TKey  key,
TValue  fallback = default(TValue) 
)
inlinestatic

Definition at line 357 of file ClassExtension.cs.

358 {
359 TValue value = default(TValue);
360 if (key != null && source.TryGetValue(key, out value))
361 {
362 return value;
363 }
364 return fallback;
365 }

◆ Within() [1/2]

static bool ClassExtension.Within ( this byte  v,
byte  v2,
byte  range 
)
inlinestatic

Definition at line 168 of file ClassExtension.cs.

169 {
170 if (v - v2 >= range)
171 {
172 return v - v2 < -range;
173 }
174 return true;
175 }

◆ Within() [2/2]

static bool ClassExtension.Within ( this int  v,
int  v2,
int  range 
)
inlinestatic

Definition at line 159 of file ClassExtension.cs.

160 {
161 if (v - v2 >= range)
162 {
163 return v - v2 < -range;
164 }
165 return true;
166 }

Member Data Documentation

◆ pluralizer

IPluralize ClassExtension.pluralizer = new Pluralizer()
static

Definition at line 17 of file ClassExtension.cs.

Referenced by AddArticle(), and langPlural().

◆ vector3


The documentation for this class was generated from the following file: