Elin Decompiled Documentation EA 23.353 Nightly
Loading...
Searching...
No Matches
ClassExtension Class Reference

Classes

class  EnumNames
 
class  EnumSize
 

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[] langList (this string s)
 
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 void Sort< T > (this IList< T > list, Func< T, int > keySelector)
 
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 string[] SplitByNewline (this string text)
 
static string RemoveNewline (this string text)
 
static string RemoveAllTags (this string text)
 
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 long ToLong (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 bool HasTag (this string s, string id, char splitter='/')
 
static string SetTag (this string s, string id, bool enable, char splitter='/')
 
static string AddTag (this string s, string id, char splitter='/')
 
static string RemoveTag (this string s, string id, char splitter='/')
 
static string GetFullFileNameWithoutExtension (this FileInfo fileInfo)
 
static string GetFullFileNameWithoutExtension (this string path)
 
static string Pluralize (string s)
 
static string GetSpecialArticle (string a)
 
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 bool RemoveFromEnd< T > (this List< T > items, T item)
 
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 15 of file ClassExtension.cs.

Member Function Documentation

◆ _SetAnchor()

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

Definition at line 1641 of file ClassExtension.cs.

1642 {
1643 switch (anchor)
1644 {
1645 case RectPosition.TopCenter:
1646 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1647 break;
1648 case RectPosition.BottomCenter:
1649 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1650 break;
1651 case RectPosition.TopLEFT:
1652 _rect.SetAnchor(0f, 1f, 0f, 1f);
1653 break;
1654 case RectPosition.TopRIGHT:
1655 _rect.SetAnchor(1f, 1f, 1f, 1f);
1656 break;
1657 case RectPosition.BottomLEFT:
1658 _rect.SetAnchor(0f, 0f, 0f, 0f);
1659 break;
1660 case RectPosition.BottomRIGHT:
1661 _rect.SetAnchor(1f, 0f, 1f, 0f);
1662 break;
1663 case RectPosition.Left:
1664 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1665 break;
1666 case RectPosition.Right:
1667 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1668 break;
1669 default:
1670 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1671 break;
1672 }
1673 }
RectPosition
Definition: RectPosition.cs:2

◆ AddArticle() [1/2]

static string ClassExtension.AddArticle ( this string  s)
inlinestatic

Definition at line 1074 of file ClassExtension.cs.

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 }
static string GetSpecialArticle(string a)
bool addArticle
Definition: LangSetting.cs:30
Definition: Lang.cs:7
static LangSetting setting
Definition: Lang.cs:55

References LangSetting.addArticle, GetSpecialArticle(), 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 1085 of file ClassExtension.cs.

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 }
ArticleStyle
Definition: ArticleStyle.cs:2
static string Pluralize(string s)
bool pluralize
Definition: LangSetting.cs:32

References LangSetting.addArticle, GetSpecialArticle(), Pluralize(), LangSetting.pluralize, and Lang.setting.

◆ AddEulerAngles()

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

Definition at line 1967 of file ClassExtension.cs.

1968 {
1969 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1970 transform.eulerAngles = vector3;
1971 }
static Vector3 vector3

References vector3.

◆ AddEulerAnglesX()

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

Definition at line 1973 of file ClassExtension.cs.

1974 {
1975 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
1976 transform.eulerAngles = vector3;
1977 }

References vector3.

◆ AddEulerAnglesY()

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

Definition at line 1979 of file ClassExtension.cs.

1980 {
1981 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
1982 transform.eulerAngles = vector3;
1983 }

References vector3.

◆ AddEulerAnglesZ()

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

Definition at line 1985 of file ClassExtension.cs.

1986 {
1987 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
1988 transform.eulerAngles = vector3;
1989 }

References vector3.

◆ AddLocalEulerAngles()

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

Definition at line 2015 of file ClassExtension.cs.

2016 {
2017 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
2018 transform.localEulerAngles = vector3;
2019 }

References vector3.

◆ AddLocalEulerAnglesX()

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

Definition at line 2021 of file ClassExtension.cs.

2022 {
2023 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2024 transform.localEulerAngles = vector3;
2025 }

References vector3.

◆ AddLocalEulerAnglesY()

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

Definition at line 2027 of file ClassExtension.cs.

2028 {
2029 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
2030 transform.localEulerAngles = vector3;
2031 }

References vector3.

◆ AddLocalEulerAnglesZ()

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

Definition at line 2033 of file ClassExtension.cs.

2034 {
2035 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z + z);
2036 transform.localEulerAngles = vector3;
2037 }

References vector3.

◆ AddLocalPosition()

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

Definition at line 1871 of file ClassExtension.cs.

1872 {
1873 vector3.Set(transform.localPosition.x + x, transform.localPosition.y + y, transform.localPosition.z + z);
1874 transform.localPosition = vector3;
1875 }

References vector3.

◆ AddLocalPositionX()

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

Definition at line 1877 of file ClassExtension.cs.

1878 {
1879 vector3.Set(transform.localPosition.x + x, transform.localPosition.y, transform.localPosition.z);
1880 transform.localPosition = vector3;
1881 }

References vector3.

◆ AddLocalPositionY()

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

Definition at line 1883 of file ClassExtension.cs.

1884 {
1885 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1886 transform.localPosition = vector3;
1887 }

References vector3.

◆ AddLocalPositionZ()

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

Definition at line 1889 of file ClassExtension.cs.

1890 {
1891 vector3.Set(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + z);
1892 transform.localPosition = vector3;
1893 }

References vector3.

◆ AddLocalScale()

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

Definition at line 1919 of file ClassExtension.cs.

1920 {
1921 vector3.Set(transform.localScale.x + x, transform.localScale.y + y, transform.localScale.z + z);
1922 transform.localScale = vector3;
1923 }

References vector3.

◆ AddLocalScaleX()

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

Definition at line 1925 of file ClassExtension.cs.

1926 {
1927 vector3.Set(transform.localScale.x + x, transform.localScale.y, transform.localScale.z);
1928 transform.localScale = vector3;
1929 }

References vector3.

◆ AddLocalScaleY()

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

Definition at line 1931 of file ClassExtension.cs.

1932 {
1933 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1934 transform.localScale = vector3;
1935 }

References vector3.

◆ AddLocalScaleZ()

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

Definition at line 1937 of file ClassExtension.cs.

1938 {
1939 vector3.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z + z);
1940 transform.localScale = vector3;
1941 }

References vector3.

◆ AddPosition()

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

Definition at line 1823 of file ClassExtension.cs.

1824 {
1825 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1826 transform.position = vector3;
1827 }

References vector3.

◆ AddPositionX()

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

Definition at line 1829 of file ClassExtension.cs.

1830 {
1831 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1832 transform.position = vector3;
1833 }

References vector3.

◆ AddPositionY()

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

Definition at line 1835 of file ClassExtension.cs.

1836 {
1837 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1838 transform.position = vector3;
1839 }

References vector3.

◆ AddPositionZ()

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

Definition at line 1841 of file ClassExtension.cs.

1842 {
1843 vector3.Set(transform.position.x, transform.position.y, transform.position.z + z);
1844 transform.position = vector3;
1845 }

References vector3.

◆ AddTag()

static string ClassExtension.AddTag ( this string  s,
string  id,
char  splitter = '/' 
)
inlinestatic

Definition at line 1022 of file ClassExtension.cs.

1023 {
1024 if (!s.HasTag(id, splitter))
1025 {
1026 s = s + (s.IsEmpty() ? "" : ((object)splitter))?.ToString() + id;
1027 }
1028 return s;
1029 }

◆ Bracket()

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

Definition at line 84 of file ClassExtension.cs.

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 }
static string[] GetList(string id)
Definition: Lang.cs:113

References Lang.GetList().

◆ Calc()

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

Definition at line 732 of file ClassExtension.cs.

733 {
734 return Cal.Calcuate(str.Replace("p2", p2.ToString() ?? "").Replace("p", power.ToString() ?? "").Replace("e", ele.ToString() ?? "")
735 .Replace(";", ","));
736 }

◆ Clamp()

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

Definition at line 234 of file ClassExtension.cs.

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 }

◆ Clamp< TValue >()

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

Definition at line 645 of file ClassExtension.cs.

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 }

◆ ClampAngle()

static float ClassExtension.ClampAngle ( this float  angle)
inlinestatic

Definition at line 2079 of file ClassExtension.cs.

2080 {
2081 if (angle < 0f)
2082 {
2083 return 360f - (0f - angle) % 360f;
2084 }
2085 return angle % 360f;
2086 }

◆ ClampMax()

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

Definition at line 256 of file ClassExtension.cs.

257 {
258 if (v <= max)
259 {
260 return v;
261 }
262 return max;
263 }

◆ ClampMin()

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

Definition at line 247 of file ClassExtension.cs.

248 {
249 if (v >= min)
250 {
251 return v;
252 }
253 return min;
254 }

◆ Contains()

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

Definition at line 895 of file ClassExtension.cs.

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 }

◆ Copy< TValue >()

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

Definition at line 397 of file ClassExtension.cs.

398 {
399 return list.ToList();
400 }

◆ CopyKeys< TKey, TValue >()

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

Definition at line 455 of file ClassExtension.cs.

456 {
457 TKey[] array = new TKey[dict.Keys.Count];
458 dict.Keys.CopyTo(array, 0);
459 return array;
460 }

◆ CopyRect()

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

Definition at line 1369 of file ClassExtension.cs.

1370 {
1371 r.pivot = t.pivot;
1372 r.sizeDelta = t.sizeDelta;
1373 r.anchorMin = t.anchorMin;
1374 r.anchorMax = t.anchorMax;
1375 r.anchoredPosition = t.anchoredPosition;
1376 }

◆ CopyValues< TKey, TValue >()

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

Definition at line 462 of file ClassExtension.cs.

463 {
464 TValue[] array = new TValue[dict.Keys.Count];
465 dict.Values.CopyTo(array, 0);
466 return array;
467 }

◆ CreateMold< T >()

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

Definition at line 1442 of file ClassExtension.cs.

1442 : Component
1443 {
1444 T result = null;
1445 for (int i = 0; i < c.transform.childCount; i++)
1446 {
1447 T component = c.transform.GetChild(i).GetComponent<T>();
1448 if ((bool)component && (name.IsEmpty() || name == component.name))
1449 {
1450 component.gameObject.SetActive(value: false);
1451 result = component;
1452 break;
1453 }
1454 }
1455 c.DestroyChildren();
1456 return result;
1457 }

◆ DestroyChildren()

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

Definition at line 1564 of file ClassExtension.cs.

1565 {
1566 if (!component || !component.transform)
1567 {
1568 Debug.LogWarning("DestroyChlidren:" + component);
1569 return;
1570 }
1571 for (int num = component.transform.childCount - 1; num >= 0; num--)
1572 {
1573 GameObject gameObject = component.transform.GetChild(num).gameObject;
1574 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1575 {
1576 UnityEngine.Object.DestroyImmediate(gameObject);
1577 }
1578 }
1579 }

References Debug.

◆ Distance()

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

Definition at line 1757 of file ClassExtension.cs.

1758 {
1759 return Vector3.Distance(t.position, pos);
1760 }

◆ Each< TValue >()

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

Definition at line 402 of file ClassExtension.cs.

403 {
404 for (int num = list.Count - 1; num >= 0; num--)
405 {
406 action(list[num]);
407 }
408 }

◆ Evalute()

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

Definition at line 911 of file ClassExtension.cs.

912 {
913 return array[(int)Mathf.Clamp((float)(array.Length - 1) * val, 0f, array.Length - 1)];
914 }

◆ Find()

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

Definition at line 1459 of file ClassExtension.cs.

1460 {
1461 return c.Find<Transform>(name);
1462 }

◆ Find< T >()

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

Definition at line 1464 of file ClassExtension.cs.

1464 : Component
1465 {
1466 if (recursive)
1467 {
1468 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1469 foreach (T val in componentsInChildren)
1470 {
1471 if (name == null || name == val.name)
1472 {
1473 return val;
1474 }
1475 }
1476 return null;
1477 }
1478 for (int j = 0; j < c.transform.childCount; j++)
1479 {
1480 T component = c.transform.GetChild(j).GetComponent<T>();
1481 if ((bool)component && (name == null || name == component.name))
1482 {
1483 return component;
1484 }
1485 }
1486 return null;
1487 }

◆ FindMax< T >()

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

Definition at line 680 of file ClassExtension.cs.

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 }

References item.

◆ FindTagInParents()

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

Definition at line 1489 of file ClassExtension.cs.

1490 {
1491 Transform transform = c.transform;
1492 for (int i = 0; i < transform.childCount; i++)
1493 {
1494 Transform child = transform.GetChild(i);
1495 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1496 {
1497 return child.gameObject;
1498 }
1499 }
1500 if ((bool)transform.parent)
1501 {
1502 return transform.parent.FindTagInParents(tag, includeInactive);
1503 }
1504 return null;
1505 }

◆ FirstItem< TKey, TValue >()

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

Definition at line 571 of file ClassExtension.cs.

572 {
573 if (source == null)
574 {
575 return default(TValue);
576 }
577 return source[source.First().Key];
578 }

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

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

Definition at line 2051 of file ClassExtension.cs.

2052 {
2053 for (int num = items.Count - 1; num >= 0; num--)
2054 {
2055 action(items[num]);
2056 }
2057 }

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

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

Definition at line 2059 of file ClassExtension.cs.

2060 {
2061 int num = items.Count - 1;
2062 while (num >= 0 && !action(items[num]))
2063 {
2064 num--;
2065 }
2066 }

◆ FromInt2()

static float ClassExtension.FromInt2 ( this int  a)
inlinestatic

Definition at line 140 of file ClassExtension.cs.

141 {
142 return (float)a / 100f;
143 }

◆ FromInt3()

static float ClassExtension.FromInt3 ( this int  a)
inlinestatic

Definition at line 130 of file ClassExtension.cs.

131 {
132 return (float)a / 1000f;
133 }

◆ GetAnchor()

static RectPosition ClassExtension.GetAnchor ( this RectTransform  _rect)
inlinestatic

Definition at line 1682 of file ClassExtension.cs.

1683 {
1684 Vector3 position = _rect.position;
1685 int width = Screen.width;
1686 int height = Screen.height;
1687 bool flag = position.y > (float)height * 0.5f;
1688 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1689 {
1690 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1691 {
1692 return RectPosition.Center;
1693 }
1694 if (!flag)
1695 {
1696 return RectPosition.BottomCenter;
1697 }
1698 return RectPosition.TopCenter;
1699 }
1700 if (position.x < (float)width * 0.5f)
1701 {
1702 if (!flag)
1703 {
1704 return RectPosition.BottomLEFT;
1705 }
1706 return RectPosition.TopLEFT;
1707 }
1708 if (!flag)
1709 {
1710 return RectPosition.BottomRIGHT;
1711 }
1712 return RectPosition.TopRIGHT;
1713 }

◆ GetBit()

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

Definition at line 111 of file ClassExtension.cs.

112 {
113 return (pByte & (1 << bitNo)) != 0;
114 }

◆ GetComponentInChildrenExcludSelf< T >()

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

Definition at line 1507 of file ClassExtension.cs.

1507 : Component
1508 {
1509 for (int i = 0; i < c.childCount; i++)
1510 {
1511 T component = c.GetChild(i).GetComponent<T>();
1512 if ((bool)component)
1513 {
1514 return component;
1515 }
1516 }
1517 return null;
1518 }

◆ GetComponentInDirectChildren< T >()

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

Definition at line 1550 of file ClassExtension.cs.

1550 : Component
1551 {
1552 Transform transform = comp.transform;
1553 for (int i = 0; i < transform.childCount; i++)
1554 {
1555 T component = transform.GetChild(i).GetComponent<T>();
1556 if ((bool)component)
1557 {
1558 return component;
1559 }
1560 }
1561 return null;
1562 }

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

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

Definition at line 1535 of file ClassExtension.cs.

1535 : Component
1536 {
1537 List<T> list = new List<T>();
1538 Transform transform = comp.transform;
1539 for (int i = 0; i < transform.childCount; i++)
1540 {
1541 T component = transform.GetChild(i).GetComponent<T>();
1542 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1543 {
1544 list.Add(component);
1545 }
1546 }
1547 return list;
1548 }

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

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

Definition at line 1520 of file ClassExtension.cs.

1520 : Component
1521 {
1522 List<T> list = new List<T>();
1523 Transform transform = comp.transform;
1524 for (int i = 0; i < transform.childCount; i++)
1525 {
1526 T component = transform.GetChild(i).GetComponent<T>();
1527 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1528 {
1529 list.Add(component);
1530 }
1531 }
1532 return list;
1533 }

◆ GetField< T >()

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

Definition at line 280 of file ClassExtension.cs.

281 {
282 return (T)o.GetType().GetField(name).GetValue(o);
283 }

◆ GetForwardDiffPoint()

static float ClassExtension.GetForwardDiffPoint ( Vector2  forward)
inlinestaticprivate

Definition at line 1734 of file ClassExtension.cs.

1735 {
1736 if (object.Equals(forward, Vector2.up))
1737 {
1738 return 90f;
1739 }
1740 object.Equals(forward, Vector2.right);
1741 return 0f;
1742 }

References forward.

Referenced by LookAt2D().

◆ GetFullFileNameWithoutExtension() [1/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this FileInfo  fileInfo)
inlinestatic

Definition at line 1046 of file ClassExtension.cs.

1047 {
1048 return fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name);
1049 }

◆ GetFullFileNameWithoutExtension() [2/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this string  path)
inlinestatic

Definition at line 1051 of file ClassExtension.cs.

1052 {
1053 return new FileInfo(path).GetFullFileNameWithoutExtension();
1054 }

◆ GetLastChild()

static Transform ClassExtension.GetLastChild ( this Transform  trans)
inlinestatic

Definition at line 1715 of file ClassExtension.cs.

1716 {
1717 return trans.GetChild(trans.childCount - 1);
1718 }

◆ GetList< T >()

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

Definition at line 658 of file ClassExtension.cs.

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 }

◆ GetOrCreate< T >()

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

Definition at line 1354 of file ClassExtension.cs.

1354 : Component
1355 {
1356 T val = t.gameObject.GetComponent<T>();
1357 if (!val)
1358 {
1359 val = t.gameObject.AddComponent<T>();
1360 }
1361 return val;
1362 }

◆ GetOrCreate< TKey, TValue >()

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

Definition at line 444 of file ClassExtension.cs.

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 }

◆ GetProperty< T >()

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

Definition at line 290 of file ClassExtension.cs.

291 {
292 return (T)o.GetType().GetProperty(name).GetValue(o);
293 }

◆ GetRuntimeEventCount()

static int ClassExtension.GetRuntimeEventCount ( this UnityEventBase  unityEvent)
inlinestatic

Definition at line 2101 of file ClassExtension.cs.

2102 {
2103 Type typeFromHandle = typeof(UnityEventBase);
2104 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2105 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2106 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2107 Type type3 = typeof(List<>).MakeGenericType(type2);
2108 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2109 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2110 object value = field.GetValue(unityEvent);
2111 object value2 = field2.GetValue(value);
2112 return (int)type3.GetProperty("Count").GetValue(value2, null);
2113 }

◆ GetSelectable()

static Selectable ClassExtension.GetSelectable ( this GameObject  go)
inlinestatic

Definition at line 1400 of file ClassExtension.cs.

1401 {
1402 return go.GetComponentInChildren<Selectable>();
1403 }

◆ GetSpecialArticle()

static string ClassExtension.GetSpecialArticle ( string  a)
inlinestatic

Definition at line 1065 of file ClassExtension.cs.

1066 {
1067 if (a.ToLower() == "unicorn")
1068 {
1069 return "a ";
1070 }
1071 return null;
1072 }

Referenced by AddArticle().

◆ HasField< T >()

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

Definition at line 270 of file ClassExtension.cs.

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 }

◆ HasTag()

static bool ClassExtension.HasTag ( this string  s,
string  id,
char  splitter = '/' 
)
inlinestatic

Definition at line 1011 of file ClassExtension.cs.

1012 {
1013 return s.Split(splitter).Contains(id);
1014 }

◆ IndexOf()

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

Definition at line 364 of file ClassExtension.cs.

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 }

◆ Instantiate< T >()

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

Definition at line 2093 of file ClassExtension.cs.

2093 : ScriptableObject
2094 {
2095 string name = s.name;
2096 T val = UnityEngine.Object.Instantiate(s);
2097 val.name = name;
2098 return val;
2099 }

◆ IsChildOf()

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

Definition at line 1424 of file ClassExtension.cs.

1425 {
1426 if (c.transform == root.transform)
1427 {
1428 return true;
1429 }
1430 if ((bool)c.transform.parent)
1431 {
1432 return c.transform.parent.gameObject.IsChildOf(root);
1433 }
1434 return false;
1435 }

◆ IsEmpty() [1/3]

static bool ClassExtension.IsEmpty ( this Array  array)
inlinestatic

Definition at line 355 of file ClassExtension.cs.

356 {
357 if (array != null)
358 {
359 return array.Length == 0;
360 }
361 return true;
362 }

◆ IsEmpty() [2/3]

static bool ClassExtension.IsEmpty ( this string  str)
inlinestatic

Definition at line 852 of file ClassExtension.cs.

853 {
854 if (str != null)
855 {
856 return str == "";
857 }
858 return true;
859 }

◆ IsEmpty() [3/3]

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

Definition at line 861 of file ClassExtension.cs.

862 {
863 if (str != null && !(str == ""))
864 {
865 return str;
866 }
867 return defaultStr;
868 }

◆ IsInteractable()

static bool ClassExtension.IsInteractable ( this GameObject  obj)
inlinestatic

Definition at line 1414 of file ClassExtension.cs.

1415 {
1416 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1417 if ((bool)selectable)
1418 {
1419 return selectable.interactable;
1420 }
1421 return false;
1422 }

◆ IsMouseOver()

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

Definition at line 1581 of file ClassExtension.cs.

1582 {
1583 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1584 }

◆ IsNull()

static bool ClassExtension.IsNull ( this object  o)
inlinestatic

Definition at line 158 of file ClassExtension.cs.

159 {
160 return o == null;
161 }

◆ IsOn()

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

Definition at line 163 of file ClassExtension.cs.

164 {
165 BitArray32 bitArray = default(BitArray32);
166 bitArray.SetInt(data);
167 return bitArray[digit];
168 }
void SetInt(int i)
Definition: BitArray32.cs:89

References BitArray32.SetInt().

◆ IsPrefab()

static bool ClassExtension.IsPrefab ( this Component  c)
inlinestatic

Definition at line 1437 of file ClassExtension.cs.

1438 {
1439 return c.gameObject.scene.name == null;
1440 }

◆ lang() [1/2]

static string ClassExtension.lang ( this string  s)
inlinestatic

Definition at line 48 of file ClassExtension.cs.

49 {
50 return Lang.Get(s);
51 }
static string Get(string id)
Definition: Lang.cs:90

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 59 of file ClassExtension.cs.

60 {
61 return Lang.Parse(s, ref1, ref2, ref3, ref4, ref5);
62 }
static string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null, string val5=null)
Definition: Lang.cs:146

References Lang.Parse().

◆ langGame() [1/2]

static string ClassExtension.langGame ( this string  s)
inlinestatic

Definition at line 69 of file ClassExtension.cs.

70 {
71 return Lang.Game.Get(s);
72 }
static LangGame Game
Definition: Lang.cs:49
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 74 of file ClassExtension.cs.

75 {
76 return Lang.Game.Parse(s, ref1, ref2, ref3, ref4);
77 }
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().

◆ langList()

static string[] ClassExtension.langList ( this string  s)
inlinestatic

Definition at line 64 of file ClassExtension.cs.

65 {
66 return Lang.GetList(s);
67 }

References Lang.GetList().

◆ langPlural()

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

Definition at line 53 of file ClassExtension.cs.

54 {
55 string text = Lang.Get(s);
56 return Lang.Parse((i <= 1 || !Lang.setting.pluralize) ? text : pluralizer.Pluralize(text), i.ToString() ?? "");
57 }
static IPluralize pluralizer

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 580 of file ClassExtension.cs.

581 {
582 if (source.Count != 0)
583 {
584 return source[source.Count - 1];
585 }
586 return default(TValue);
587 }

◆ LookAt2D() [1/2]

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

Definition at line 1744 of file ClassExtension.cs.

1745 {
1746 self.LookAt2D(target.position, forward);
1747 }

References forward.

◆ LookAt2D() [2/2]

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

Definition at line 1749 of file ClassExtension.cs.

1750 {
1751 float forwardDiffPoint = GetForwardDiffPoint(forward);
1752 Vector3 vector = target - self.position;
1753 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1754 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1755 }
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 1180 of file ClassExtension.cs.

1181 {
1182 for (int i = 0; i < sels.Count; i++)
1183 {
1184 Selectable selectable = sels[i];
1185 Selectable selectable2 = sels[0];
1186 Navigation navigation = selectable.navigation;
1187 if (horizonal)
1188 {
1189 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1190 }
1191 if (asGroup)
1192 {
1193 for (int j = i + 1; j < sels.Count; j++)
1194 {
1195 if (sels[j].transform.position.y < selectable.transform.position.y)
1196 {
1197 selectable2 = sels[j];
1198 break;
1199 }
1200 }
1201 }
1202 else
1203 {
1204 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1205 }
1206 if (vertical)
1207 {
1208 navigation.selectOnDown = selectable2;
1209 }
1210 selectable.navigation = navigation;
1211 }
1212 for (int num = sels.Count - 1; num >= 0; num--)
1213 {
1214 Selectable selectable3 = sels[num];
1215 Selectable selectable4 = sels[sels.Count - 1];
1216 Navigation navigation2 = selectable3.navigation;
1217 if (horizonal)
1218 {
1219 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1220 }
1221 if (asGroup)
1222 {
1223 int num2 = sels.Count - 1;
1224 for (int num3 = num - 1; num3 >= 0; num3--)
1225 {
1226 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1227 {
1228 num2 = num3;
1229 break;
1230 }
1231 }
1232 int num4 = num2;
1233 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1234 {
1235 selectable4 = sels[num4];
1236 num4--;
1237 }
1238 }
1239 else
1240 {
1241 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1242 }
1243 if (vertical)
1244 {
1245 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1246 }
1247 navigation2.mode = Navigation.Mode.Explicit;
1248 selectable3.navigation = navigation2;
1249 }
1250 }

◆ LoopSelectable() [2/2]

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

Definition at line 1252 of file ClassExtension.cs.

1253 {
1254 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1255 for (int num = list.Count - 1; num >= 0; num--)
1256 {
1257 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1258 {
1259 list.RemoveAt(num);
1260 }
1261 }
1262 list.LoopSelectable(vertical, horizonal, asGroup);
1263 }

◆ LoopTail< T >()

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

Definition at line 1132 of file ClassExtension.cs.

1132 : Selectable
1133 {
1134 if (list.Count > 1)
1135 {
1136 Navigation navigation = list[0].navigation;
1137 Navigation navigation2 = list[list.Count - 1].navigation;
1138 if (vertical)
1139 {
1140 navigation.selectOnUp = list[list.Count - 1];
1141 navigation2.selectOnDown = list[0];
1142 }
1143 else
1144 {
1145 navigation.selectOnLeft = list[list.Count - 1];
1146 navigation2.selectOnRight = list[0];
1147 }
1148 list[0].navigation = navigation;
1149 list[list.Count - 1].navigation = navigation2;
1150 }
1151 }

◆ Minimum()

static int ClassExtension.Minimum ( this int  i)
inlinestatic

Definition at line 145 of file ClassExtension.cs.

146 {
147 if (i != 0)
148 {
149 if (i <= 0)
150 {
151 return -1;
152 }
153 return 1;
154 }
155 return 0;
156 }

◆ Move< TValue >()

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

Definition at line 380 of file ClassExtension.cs.

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 }

◆ Multiply()

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

Definition at line 1288 of file ClassExtension.cs.

1289 {
1290 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1291 }

References Color.

◆ NextEnum< T >()

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

Definition at line 206 of file ClassExtension.cs.

206 : struct
207 {
208 return ((T[])Enum.GetValues(src.GetType())).NextItem(src);
209 }

◆ NextIndex< TValue >()

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

Definition at line 603 of file ClassExtension.cs.

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 }

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

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

Definition at line 589 of file ClassExtension.cs.

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 }

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

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

Definition at line 617 of file ClassExtension.cs.

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 }

◆ Parentheses()

static string ClassExtension.Parentheses ( this string  str)
inlinestatic

Definition at line 79 of file ClassExtension.cs.

80 {
81 return "(" + str + ")";
82 }

◆ Pluralize()

static string ClassExtension.Pluralize ( string  s)
inlinestatic

Definition at line 1056 of file ClassExtension.cs.

1057 {
1058 if (s == "talisman")
1059 {
1060 return "talismans";
1061 }
1062 return pluralizer.Pluralize(s);
1063 }

References pluralizer.

Referenced by AddArticle().

◆ Plus()

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

Definition at line 1762 of file ClassExtension.cs.

1763 {
1764 v.x += v2.x;
1765 v.y += v2.y;
1766 return v;
1767 }

◆ PlusX()

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

Definition at line 1781 of file ClassExtension.cs.

1782 {
1783 v.x += a;
1784 return v;
1785 }

◆ PlusY()

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

Definition at line 1787 of file ClassExtension.cs.

1788 {
1789 v.y += a;
1790 return v;
1791 }

◆ PlusZ()

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

Definition at line 1793 of file ClassExtension.cs.

1794 {
1795 v.z += a;
1796 return v;
1797 }

◆ PrevEnum< T >()

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

Definition at line 211 of file ClassExtension.cs.

211 : struct
212 {
213 return ((T[])Enum.GetValues(src.GetType())).PrevItem(src);
214 }

◆ PrevItem< TValue >()

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

Definition at line 631 of file ClassExtension.cs.

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 }

◆ Random()

static Vector3 ClassExtension.Random ( this Vector3  v)
inlinestatic

Definition at line 2088 of file ClassExtension.cs.

2089 {
2090 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2091 }
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49

References Rand.Range().

◆ RandomItem< T >()

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

Definition at line 469 of file ClassExtension.cs.

470 {
471 int num = ie.Count();
472 if (num == 0)
473 {
474 return default(T);
475 }
476 return ie.ElementAt(Rand.rnd(num));
477 }
static int rnd(int max)
Definition: Rand.cs:59

References Rand.rnd().

◆ RandomItem< TKey, TValue >()

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

Definition at line 479 of file ClassExtension.cs.

480 {
481 if (source.Count != 0)
482 {
483 return source.ElementAt(Rand.rnd(source.Count)).Value;
484 }
485 return default(TValue);
486 }

References Rand.rnd().

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

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

Definition at line 488 of file ClassExtension.cs.

489 {
490 if (source.Count != 0)
491 {
492 return source[Rand.rnd(source.Count)];
493 }
494 return default(TValue);
495 }

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 521 of file ClassExtension.cs.

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 }

References Rand.rnd().

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

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

Definition at line 502 of file ClassExtension.cs.

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 }

References Rand.rnd().

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

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

Definition at line 497 of file ClassExtension.cs.

498 {
499 return source.RandomItem(source.IndexOf(exclude));
500 }

◆ RandomItemWeighted< TValue >()

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

Definition at line 534 of file ClassExtension.cs.

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 }

References item, and Rand.Range().

◆ RebuildLayout()

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

Definition at line 1586 of file ClassExtension.cs.

1587 {
1588 if (recursive)
1589 {
1590 foreach (Transform item in c.transform)
1591 {
1592 if (item is RectTransform)
1593 {
1594 item.RebuildLayout(recursive: true);
1595 }
1596 }
1597 }
1598 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1599 }

References item.

◆ RebuildLayoutTo()

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

Definition at line 1610 of file ClassExtension.cs.

1611 {
1612 c.RebuildLayout();
1613 if (!(c == target) && (bool)c.transform.parent)
1614 {
1615 c.transform.parent.RebuildLayoutTo(target);
1616 }
1617 }

◆ RebuildLayoutTo< T >()

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

Definition at line 1601 of file ClassExtension.cs.

1601 : Component
1602 {
1603 c.RebuildLayout();
1604 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1605 {
1606 c.transform.parent.RebuildLayoutTo<T>();
1607 }
1608 }

◆ Rect()

static RectTransform ClassExtension.Rect ( this Component  c)
inlinestatic

Definition at line 1364 of file ClassExtension.cs.

1365 {
1366 return c.transform as RectTransform;
1367 }

◆ Remainder< TValue >()

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

Definition at line 562 of file ClassExtension.cs.

563 {
564 if (source.Count != 0)
565 {
566 return source[divider % source.Count];
567 }
568 return default(TValue);
569 }

◆ RemoveAllTags()

static string ClassExtension.RemoveAllTags ( this string  text)
inlinestatic

Definition at line 723 of file ClassExtension.cs.

724 {
725 if (string.IsNullOrEmpty(text))
726 {
727 return text;
728 }
729 return Regex.Replace(text, "<.*?>", "");
730 }

◆ RemoveFromEnd< T >()

static bool ClassExtension.RemoveFromEnd< T > ( this List< T >  items,
T  item 
)
inlinestatic

Definition at line 2068 of file ClassExtension.cs.

2069 {
2070 int num = items.LastIndexOf(item);
2071 if (num < 0)
2072 {
2073 return false;
2074 }
2075 items.RemoveAt(num);
2076 return true;
2077 }

References item.

◆ RemoveNewline()

static string ClassExtension.RemoveNewline ( this string  text)
inlinestatic

Definition at line 714 of file ClassExtension.cs.

715 {
716 if (string.IsNullOrEmpty(text))
717 {
718 return text;
719 }
720 return text.Replace("\r", "").Replace("\n", "");
721 }

◆ RemoveTag()

static string ClassExtension.RemoveTag ( this string  s,
string  id,
char  splitter = '/' 
)
inlinestatic

Definition at line 1031 of file ClassExtension.cs.

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 }

◆ Repeat()

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

Definition at line 827 of file ClassExtension.cs.

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 }

◆ Set< T1, T2 >()

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

Definition at line 696 of file ClassExtension.cs.

697 {
698 dic.Clear();
699 foreach (KeyValuePair<T1, T2> item in from)
700 {
701 dic[item.Key] = item.Value;
702 }
703 }

References item.

◆ SetActive() [1/2]

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

Definition at line 1383 of file ClassExtension.cs.

1384 {
1385 if (c.gameObject.activeSelf != enable)
1386 {
1387 c.gameObject.SetActive(enable);
1388 }
1389 }

Referenced by ContentQuest.RefreshTrackButtons().

◆ SetActive() [2/2]

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

Definition at line 1391 of file ClassExtension.cs.

1392 {
1393 if (c.gameObject.activeSelf != enable)
1394 {
1395 c.gameObject.SetActive(enable);
1396 onChangeState(enable);
1397 }
1398 }

◆ SetAlpha() [1/4]

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

Definition at line 1282 of file ClassExtension.cs.

1283 {
1284 c.a = a;
1285 return c;
1286 }

◆ SetAlpha() [2/4]

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

Definition at line 1272 of file ClassExtension.cs.

1273 {
1274 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1275 }

References Color.

◆ SetAlpha() [3/4]

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

Definition at line 1277 of file ClassExtension.cs.

1278 {
1279 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1280 }

References Color.

◆ SetAlpha() [4/4]

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

Definition at line 1321 of file ClassExtension.cs.

1322 {
1323 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1324 }

References Color.

◆ SetAnchor() [1/2]

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

Definition at line 1675 of file ClassExtension.cs.

1676 {
1677 Vector3 position = _rect.position;
1678 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1679 _rect.position = position;
1680 }

◆ SetAnchor() [2/2]

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

Definition at line 1635 of file ClassExtension.cs.

1636 {
1637 r.anchorMin = new Vector2(minX, minY);
1638 r.anchorMax = new Vector2(maxX, maxY);
1639 }

◆ SetBit()

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

Definition at line 116 of file ClassExtension.cs.

117 {
118 if (!value)
119 {
120 return Convert.ToByte(pByte & ~(1 << bitNo));
121 }
122 return Convert.ToByte(pByte | (1 << bitNo));
123 }

◆ SetEulerAngles()

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

Definition at line 1943 of file ClassExtension.cs.

1944 {
1945 vector3.Set(x, y, z);
1946 transform.eulerAngles = vector3;
1947 }

References vector3.

◆ SetEulerAnglesX()

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

Definition at line 1949 of file ClassExtension.cs.

1950 {
1951 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1952 transform.eulerAngles = vector3;
1953 }

References vector3.

◆ SetEulerAnglesY()

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

Definition at line 1955 of file ClassExtension.cs.

1956 {
1957 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1958 transform.eulerAngles = vector3;
1959 }

References vector3.

◆ SetEulerAnglesZ()

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

Definition at line 1961 of file ClassExtension.cs.

1962 {
1963 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
1964 transform.eulerAngles = vector3;
1965 }

References vector3.

◆ SetField< T >()

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

Definition at line 285 of file ClassExtension.cs.

286 {
287 o.GetType().GetField(name).SetValue(o, value);
288 }

◆ SetLayerRecursively()

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

Definition at line 1405 of file ClassExtension.cs.

1406 {
1407 obj.layer = layer;
1408 foreach (Transform item in obj.transform)
1409 {
1410 item.gameObject.SetLayerRecursively(layer);
1411 }
1412 }

References item.

◆ SetListener()

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

Definition at line 1312 of file ClassExtension.cs.

1313 {
1314 e.RemoveAllListeners();
1315 e.AddListener(delegate
1316 {
1317 action();
1318 });
1319 }

References Button.

◆ SetLocalEulerAngles()

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

Definition at line 1991 of file ClassExtension.cs.

1992 {
1993 vector3.Set(x, y, z);
1994 transform.localEulerAngles = vector3;
1995 }

References vector3.

◆ SetLocalEulerAnglesX()

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

Definition at line 1997 of file ClassExtension.cs.

1998 {
1999 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2000 transform.localEulerAngles = vector3;
2001 }

References vector3.

◆ SetLocalEulerAnglesY()

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

Definition at line 2003 of file ClassExtension.cs.

2004 {
2005 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
2006 transform.localEulerAngles = vector3;
2007 }

References vector3.

◆ SetLocalEulerAnglesZ()

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

Definition at line 2009 of file ClassExtension.cs.

2010 {
2011 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
2012 transform.localEulerAngles = vector3;
2013 }

References vector3.

◆ SetLocalPosition()

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

Definition at line 1847 of file ClassExtension.cs.

1848 {
1849 vector3.Set(x, y, z);
1850 transform.localPosition = vector3;
1851 }

References vector3.

◆ SetLocalPositionX()

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

Definition at line 1853 of file ClassExtension.cs.

1854 {
1855 vector3.Set(x, transform.localPosition.y, transform.localPosition.z);
1856 transform.localPosition = vector3;
1857 }

References vector3.

◆ SetLocalPositionY()

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

Definition at line 1859 of file ClassExtension.cs.

1860 {
1861 vector3.Set(transform.localPosition.x, y, transform.localPosition.z);
1862 transform.localPosition = vector3;
1863 }

References vector3.

◆ SetLocalPositionZ()

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

Definition at line 1865 of file ClassExtension.cs.

1866 {
1867 vector3.Set(transform.localPosition.x, transform.localPosition.y, z);
1868 transform.localPosition = vector3;
1869 }

References vector3.

◆ SetLocalScale()

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

Definition at line 1895 of file ClassExtension.cs.

1896 {
1897 vector3.Set(x, y, z);
1898 transform.localScale = vector3;
1899 }

References vector3.

◆ SetLocalScaleX()

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

Definition at line 1901 of file ClassExtension.cs.

1902 {
1903 vector3.Set(x, transform.localScale.y, transform.localScale.z);
1904 transform.localScale = vector3;
1905 }

References vector3.

◆ SetLocalScaleY()

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

Definition at line 1907 of file ClassExtension.cs.

1908 {
1909 vector3.Set(transform.localScale.x, y, transform.localScale.z);
1910 transform.localScale = vector3;
1911 }

References vector3.

◆ SetLocalScaleZ()

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

Definition at line 1913 of file ClassExtension.cs.

1914 {
1915 vector3.Set(transform.localScale.x, transform.localScale.y, z);
1916 transform.localScale = vector3;
1917 }

References vector3.

◆ SetNavigation()

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

Definition at line 1153 of file ClassExtension.cs.

1154 {
1155 if (!a || !b)
1156 {
1157 return;
1158 }
1159 Selectable component = a.GetComponent<Selectable>();
1160 Selectable component2 = b.GetComponent<Selectable>();
1161 if ((bool)component && (bool)component2)
1162 {
1163 Navigation navigation = component.navigation;
1164 Navigation navigation2 = component2.navigation;
1165 if (vertical)
1166 {
1167 navigation.selectOnUp = component2;
1168 navigation2.selectOnDown = component;
1169 }
1170 else
1171 {
1172 navigation.selectOnLeft = component2;
1173 navigation2.selectOnRight = component;
1174 }
1175 component.navigation = navigation;
1176 component2.navigation = navigation2;
1177 }
1178 }

◆ SetOnClick()

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

Definition at line 1303 of file ClassExtension.cs.

1304 {
1305 b.onClick.RemoveAllListeners();
1306 b.onClick.AddListener(delegate
1307 {
1308 action();
1309 });
1310 }

◆ SetPivot()

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

Definition at line 1630 of file ClassExtension.cs.

1631 {
1632 r.pivot = new Vector2(x, y);
1633 }

◆ SetPosition()

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

Definition at line 1799 of file ClassExtension.cs.

1800 {
1801 vector3.Set(x, y, z);
1802 transform.position = vector3;
1803 }

References vector3.

◆ SetPositionX()

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

Definition at line 1805 of file ClassExtension.cs.

1806 {
1807 vector3.Set(x, transform.position.y, transform.position.z);
1808 transform.position = vector3;
1809 }

References vector3.

◆ SetPositionY()

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

Definition at line 1811 of file ClassExtension.cs.

1812 {
1813 vector3.Set(transform.position.x, y, transform.position.z);
1814 transform.position = vector3;
1815 }

References vector3.

◆ SetPositionZ()

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

Definition at line 1817 of file ClassExtension.cs.

1818 {
1819 vector3.Set(transform.position.x, transform.position.y, z);
1820 transform.position = vector3;
1821 }

References vector3.

◆ SetProperty< T >()

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

Definition at line 295 of file ClassExtension.cs.

296 {
297 o.GetType().GetProperty(name).SetValue(o, value);
298 }

◆ 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 1619 of file ClassExtension.cs.

1620 {
1621 r.SetPivot(pivotX, pivotY);
1622 r.SetAnchor(minX, minY, maxX, maxY);
1623 if (w != -1f)
1624 {
1625 r.sizeDelta = new Vector2(w, h);
1626 }
1627 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1628 }

◆ SetScale()

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

Definition at line 1725 of file ClassExtension.cs.

1726 {
1727 float x = renderer.bounds.size.x;
1728 float y = renderer.bounds.size.y;
1729 float x2 = size / x;
1730 float y2 = size / y;
1731 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1732 }

◆ SetSlider() [1/2]

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

Definition at line 1326 of file ClassExtension.cs.

1327 {
1328 slider.SetSlider(value, action, -1, -1, notify);
1329 }

◆ 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 1331 of file ClassExtension.cs.

1332 {
1333 slider.onValueChanged.RemoveAllListeners();
1334 slider.onValueChanged.AddListener(delegate(float a)
1335 {
1336 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1337 });
1338 if (min != -1)
1339 {
1340 slider.minValue = min;
1341 slider.maxValue = max;
1342 }
1343 if (notify)
1344 {
1345 slider.value = value;
1346 }
1347 else
1348 {
1349 slider.SetValueWithoutNotify(value);
1350 }
1351 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1352 }

◆ SetTag()

static string ClassExtension.SetTag ( this string  s,
string  id,
bool  enable,
char  splitter = '/' 
)
inlinestatic

Definition at line 1016 of file ClassExtension.cs.

1017 {
1018 s = ((!enable) ? s.RemoveTag(id, splitter) : s.AddTag(id, splitter));
1019 return s;
1020 }

◆ SetY()

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

Definition at line 1775 of file ClassExtension.cs.

1776 {
1777 v.y = a;
1778 return v;
1779 }

◆ SetZ()

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

Definition at line 1769 of file ClassExtension.cs.

1770 {
1771 v.z = a;
1772 return v;
1773 }

◆ Shuffle< TValue >()

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

Definition at line 410 of file ClassExtension.cs.

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 }
static Random _random
Definition: Rand.cs:9

References Rand._random.

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

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

Definition at line 300 of file ClassExtension.cs.

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 }

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

static void ClassExtension.Sort< T > ( this IList< T >  list,
Func< T, int >  keySelector 
)
inlinestatic

Definition at line 315 of file ClassExtension.cs.

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 }

References item.

◆ SplitByNewline()

static string[] ClassExtension.SplitByNewline ( this string  text)
inlinestatic

Definition at line 705 of file ClassExtension.cs.

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 }

◆ SplitNewline()

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

Definition at line 890 of file ClassExtension.cs.

891 {
892 return str.Split(Environment.NewLine.ToCharArray());
893 }

◆ SplitToInts()

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

Definition at line 879 of file ClassExtension.cs.

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 }

◆ StripBrackets()

static string ClassExtension.StripBrackets ( this string  str)
inlinestatic

Definition at line 837 of file ClassExtension.cs.

838 {
839 HashSet<char> brackets = new HashSet<char> { '"', '「', '」', '“', '”' };
840 return string.Concat(str.Where((char c) => !brackets.Contains(c)));
841 }

◆ StripLastPun()

static string ClassExtension.StripLastPun ( this string  str)
inlinestatic

Definition at line 791 of file ClassExtension.cs.

792 {
793 if (str != null)
794 {
795 return str.TrimEnd(Lang.words.period);
796 }
797 return str;
798 }
char period
Definition: Lang.cs:20
static Words words
Definition: Lang.cs:27

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

◆ StripPun()

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

Definition at line 800 of file ClassExtension.cs.

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 }
char comma
Definition: Lang.cs:18

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

◆ Tag()

static string ClassExtension.Tag ( this Color  c)
inlinestatic

Definition at line 1293 of file ClassExtension.cs.

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

References $.

◆ TagColor() [1/2]

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

Definition at line 996 of file ClassExtension.cs.

997 {
998 return "<color=" + c.ToHex() + ">" + s + "</color>";
999 }

◆ TagColor() [2/2]

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

Definition at line 991 of file ClassExtension.cs.

992 {
993 return s + "<color=" + c.ToHex() + ">" + txt + "</color>";
994 }

◆ TagSize() [1/2]

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

Definition at line 1006 of file ClassExtension.cs.

1007 {
1008 return "<size=" + size + ">" + s + "</size>";
1009 }

◆ TagSize() [2/2]

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

Definition at line 1001 of file ClassExtension.cs.

1002 {
1003 return s + "<size=" + size + ">" + txt + "</size>";
1004 }

◆ ToBytes()

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

Definition at line 104 of file ClassExtension.cs.

105 {
106 byte[] array = new byte[(bits.Length - 1) / 8 + 1];
107 bits.CopyTo(array, 0);
108 return array;
109 }

◆ ToColor()

static Color ClassExtension.ToColor ( this string  s)
inlinestatic

Definition at line 1265 of file ClassExtension.cs.

1266 {
1267 Color color = Color.white;
1268 ColorUtility.TryParseHtmlString("#" + s, out color);
1269 return color;
1270 }

References Color.

◆ ToDictionary< T >()

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

Definition at line 671 of file ClassExtension.cs.

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 }

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

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

Definition at line 170 of file ClassExtension.cs.

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 }

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

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

Definition at line 179 of file ClassExtension.cs.

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 }

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

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

Definition at line 188 of file ClassExtension.cs.

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 }

◆ ToField< T >()

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

Definition at line 265 of file ClassExtension.cs.

266 {
267 return (T)o.GetType().GetField(s).GetValue(o);
268 }

◆ ToFloat()

static float ClassExtension.ToFloat ( this string  str)
inlinestatic

Definition at line 772 of file ClassExtension.cs.

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 }

References Debug.

◆ ToFormat() [1/2]

static string ClassExtension.ToFormat ( this int  a)
inlinestatic

Definition at line 959 of file ClassExtension.cs.

960 {
961 return $"{a:#,0}";
962 }

References $.

◆ ToFormat() [2/2]

static string ClassExtension.ToFormat ( this long  a)
inlinestatic

Definition at line 964 of file ClassExtension.cs.

965 {
966 return $"{a:#,0}";
967 }

References $.

◆ ToggleActive()

static void ClassExtension.ToggleActive ( this Component  c)
inlinestatic

Definition at line 1378 of file ClassExtension.cs.

1379 {
1380 c.SetActive(!c.gameObject.activeSelf);
1381 }

◆ ToggleKeyword()

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

Definition at line 2039 of file ClassExtension.cs.

2040 {
2041 if (enable)
2042 {
2043 m.EnableKeyword(id);
2044 }
2045 else
2046 {
2047 m.DisableKeyword(id);
2048 }
2049 }

◆ ToHex()

static string ClassExtension.ToHex ( this Color  c)
inlinestatic

Definition at line 1298 of file ClassExtension.cs.

1299 {
1300 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1301 }

References $.

◆ ToInt() [1/2]

static int ClassExtension.ToInt ( this string  str)
inlinestatic

Definition at line 754 of file ClassExtension.cs.

755 {
756 if (int.TryParse(str, out var result))
757 {
758 return result;
759 }
760 return 0;
761 }

◆ ToInt() [2/2]

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

Definition at line 743 of file ClassExtension.cs.

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 }

References Debug.

◆ ToInt2()

static int ClassExtension.ToInt2 ( this float  a)
inlinestatic

Definition at line 135 of file ClassExtension.cs.

136 {
137 return (int)(a * 100f);
138 }

◆ ToInt3()

static int ClassExtension.ToInt3 ( this float  a)
inlinestatic

Definition at line 125 of file ClassExtension.cs.

126 {
127 return (int)(a * 1000f);
128 }

◆ ToInt< T >()

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

Definition at line 738 of file ClassExtension.cs.

739 {
740 return str.ToInt(typeof(T));
741 }

◆ ToLong()

static long ClassExtension.ToLong ( this string  str)
inlinestatic

Definition at line 763 of file ClassExtension.cs.

764 {
765 if (long.TryParse(str, out var result))
766 {
767 return result;
768 }
769 return 0L;
770 }

◆ ToShortNumber()

static string ClassExtension.ToShortNumber ( this int  a)
inlinestatic

Definition at line 916 of file ClassExtension.cs.

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 }

◆ ToText()

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

Definition at line 969 of file ClassExtension.cs.

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 }

◆ ToTitleCase()

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

Definition at line 1105 of file ClassExtension.cs.

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 }
bool capitalize
Definition: LangSetting.cs:34

References LangSetting.capitalize, and Lang.setting.

◆ ToType()

static Type ClassExtension.ToType ( this string  value)
inlinestatic

Definition at line 201 of file ClassExtension.cs.

202 {
203 return Type.GetType("Elona." + value + ", Assembly-CSharp");
204 }

◆ ToVector2()

static Vector2 ClassExtension.ToVector2 ( this Vector3  self)
inlinestatic

Definition at line 1720 of file ClassExtension.cs.

1721 {
1722 return new Vector2(self.x, self.z);
1723 }

◆ TrimNewLines()

static string ClassExtension.TrimNewLines ( this string  text)
inlinestatic

Definition at line 870 of file ClassExtension.cs.

871 {
872 while (text.EndsWith(Environment.NewLine))
873 {
874 text = text.Substring(0, text.Length - Environment.NewLine.Length);
875 }
876 return text;
877 }

◆ TryAddExtension()

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

Definition at line 843 of file ClassExtension.cs.

844 {
845 if (!s.Contains("." + ext))
846 {
847 return s + "." + ext;
848 }
849 return s;
850 }

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

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

Definition at line 346 of file ClassExtension.cs.

347 {
348 if (index >= array.Count)
349 {
350 return default(TValue);
351 }
352 return array[index];
353 }

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

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

Definition at line 325 of file ClassExtension.cs.

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 }

◆ 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 434 of file ClassExtension.cs.

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 }

◆ 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 424 of file ClassExtension.cs.

425 {
426 TValue value = default(TValue);
427 if (key != null && source.TryGetValue(key, out value))
428 {
429 return value;
430 }
431 return fallback;
432 }

◆ Within() [1/2]

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

Definition at line 225 of file ClassExtension.cs.

226 {
227 if (v - v2 >= range)
228 {
229 return v - v2 < -range;
230 }
231 return true;
232 }

◆ Within() [2/2]

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

Definition at line 216 of file ClassExtension.cs.

217 {
218 if (v - v2 >= range)
219 {
220 return v - v2 < -range;
221 }
222 return true;
223 }

Member Data Documentation

◆ pluralizer

IPluralize ClassExtension.pluralizer = new Pluralizer()
static

Definition at line 46 of file ClassExtension.cs.

Referenced by langPlural(), and Pluralize().

◆ vector3


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