Elin Decompiled Documentation EA 23.335 Nightly
Loading...
Searching...
No Matches
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[] 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 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 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 14 of file ClassExtension.cs.

Member Function Documentation

◆ _SetAnchor()

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

Definition at line 1587 of file ClassExtension.cs.

1588 {
1589 switch (anchor)
1590 {
1591 case RectPosition.TopCenter:
1592 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1593 break;
1594 case RectPosition.BottomCenter:
1595 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1596 break;
1597 case RectPosition.TopLEFT:
1598 _rect.SetAnchor(0f, 1f, 0f, 1f);
1599 break;
1600 case RectPosition.TopRIGHT:
1601 _rect.SetAnchor(1f, 1f, 1f, 1f);
1602 break;
1603 case RectPosition.BottomLEFT:
1604 _rect.SetAnchor(0f, 0f, 0f, 0f);
1605 break;
1606 case RectPosition.BottomRIGHT:
1607 _rect.SetAnchor(1f, 0f, 1f, 0f);
1608 break;
1609 case RectPosition.Left:
1610 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1611 break;
1612 case RectPosition.Right:
1613 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1614 break;
1615 default:
1616 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1617 break;
1618 }
1619 }
RectPosition
Definition: RectPosition.cs:2

◆ AddArticle() [1/2]

static string ClassExtension.AddArticle ( this string  s)
inlinestatic

Definition at line 1020 of file ClassExtension.cs.

1021 {
1022 if (!Lang.setting.addArticle || s.Length < 1)
1023 {
1024 return s;
1025 }
1026 char c = s.ToLower()[0];
1027 s = (GetSpecialArticle(s) ?? ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ")) + s;
1028 return s;
1029 }
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 1031 of file ClassExtension.cs.

1032 {
1033 if (!Lang.setting.addArticle || s.Length < 1)
1034 {
1035 return s;
1036 }
1037 char c = s[0];
1038 string text = ((num >= 2) ? (num.ToFormat() + " ") : (GetSpecialArticle(s) ?? ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ")));
1039 if (num >= 2 && Lang.setting.pluralize)
1040 {
1041 s = ((replace.IsEmpty() || !s.Contains(replace) || s.Contains("limestone stone")) ? Pluralize(s) : s.Replace(replace, Pluralize(replace)));
1042 }
1043 return style switch
1044 {
1045 ArticleStyle.The => "_the".lang().ToTitleCase() + " " + ((num > 1) ? (num + " ") : "") + s,
1046 ArticleStyle.None => ((num > 1) ? (num.ToFormat() + " ") : "") + s.ToTitleCase(),
1047 _ => text + s,
1048 };
1049 }
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 1913 of file ClassExtension.cs.

1914 {
1915 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1916 transform.eulerAngles = vector3;
1917 }
static Vector3 vector3

References vector3.

◆ AddEulerAnglesX()

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

Definition at line 1919 of file ClassExtension.cs.

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

References vector3.

◆ AddEulerAnglesY()

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

Definition at line 1925 of file ClassExtension.cs.

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

References vector3.

◆ AddEulerAnglesZ()

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

Definition at line 1931 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalEulerAngles()

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

Definition at line 1961 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalEulerAnglesX()

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

Definition at line 1967 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalEulerAnglesY()

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

Definition at line 1973 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalEulerAnglesZ()

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

Definition at line 1979 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPosition()

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

Definition at line 1817 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPositionX()

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

Definition at line 1823 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPositionY()

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

Definition at line 1829 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPositionZ()

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

Definition at line 1835 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScale()

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

Definition at line 1865 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScaleX()

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

Definition at line 1871 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScaleY()

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

Definition at line 1877 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScaleZ()

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

Definition at line 1883 of file ClassExtension.cs.

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

References vector3.

◆ AddPosition()

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

Definition at line 1769 of file ClassExtension.cs.

1770 {
1771 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1772 transform.position = vector3;
1773 }

References vector3.

◆ AddPositionX()

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

Definition at line 1775 of file ClassExtension.cs.

1776 {
1777 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1778 transform.position = vector3;
1779 }

References vector3.

◆ AddPositionY()

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

Definition at line 1781 of file ClassExtension.cs.

1782 {
1783 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1784 transform.position = vector3;
1785 }

References vector3.

◆ AddPositionZ()

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

Definition at line 1787 of file ClassExtension.cs.

1788 {
1789 vector3.Set(transform.position.x, transform.position.y, transform.position.z + z);
1790 transform.position = vector3;
1791 }

References vector3.

◆ AddTag()

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

Definition at line 968 of file ClassExtension.cs.

969 {
970 if (!s.HasTag(id, splitter))
971 {
972 s = s + (s.IsEmpty() ? "" : ((object)splitter))?.ToString() + id;
973 }
974 return s;
975 }

◆ Bracket()

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

Definition at line 56 of file ClassExtension.cs.

57 {
58 switch (type)
59 {
60 case -1:
61 return str;
62 case 1:
63 case 2:
64 case 3:
65 case 4:
66 case 5:
67 {
68 string[] list = Lang.GetList("bracket_" + type);
69 return list[0] + str + list[1];
70 }
71 default:
72 return "_bracketLeft".lang() + str + "_bracketRight".lang();
73 }
74 }
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 678 of file ClassExtension.cs.

679 {
680 return Cal.Calcuate(str.Replace("p2", p2.ToString() ?? "").Replace("p", power.ToString() ?? "").Replace("e", ele.ToString() ?? "")
681 .Replace(";", ","));
682 }

◆ Clamp()

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

Definition at line 190 of file ClassExtension.cs.

191 {
192 if (v < min)
193 {
194 v = ((!loop) ? min : max);
195 }
196 else if (v > max)
197 {
198 v = ((!loop) ? max : min);
199 }
200 return v;
201 }

◆ Clamp< TValue >()

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

Definition at line 591 of file ClassExtension.cs.

592 {
593 if (i < 0)
594 {
595 i = 0;
596 }
597 else if (i >= source.Count)
598 {
599 i = source.Count - 1;
600 }
601 return source[i];
602 }

◆ ClampAngle()

static float ClassExtension.ClampAngle ( this float  angle)
inlinestatic

Definition at line 2014 of file ClassExtension.cs.

2015 {
2016 if (angle < 0f)
2017 {
2018 return 360f - (0f - angle) % 360f;
2019 }
2020 return angle % 360f;
2021 }

◆ ClampMax()

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

Definition at line 212 of file ClassExtension.cs.

213 {
214 if (v <= max)
215 {
216 return v;
217 }
218 return max;
219 }

◆ ClampMin()

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

Definition at line 203 of file ClassExtension.cs.

204 {
205 if (v >= min)
206 {
207 return v;
208 }
209 return min;
210 }

◆ Contains()

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

Definition at line 841 of file ClassExtension.cs.

842 {
843 if (strs == null || strs.Length == 0)
844 {
845 return false;
846 }
847 for (int i = 0; i < strs.Length; i++)
848 {
849 if (strs[i] == id)
850 {
851 return true;
852 }
853 }
854 return false;
855 }

◆ Copy< TValue >()

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

Definition at line 343 of file ClassExtension.cs.

344 {
345 return list.ToList();
346 }

◆ CopyKeys< TKey, TValue >()

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

Definition at line 401 of file ClassExtension.cs.

402 {
403 TKey[] array = new TKey[dict.Keys.Count];
404 dict.Keys.CopyTo(array, 0);
405 return array;
406 }

◆ CopyRect()

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

Definition at line 1315 of file ClassExtension.cs.

1316 {
1317 r.pivot = t.pivot;
1318 r.sizeDelta = t.sizeDelta;
1319 r.anchorMin = t.anchorMin;
1320 r.anchorMax = t.anchorMax;
1321 r.anchoredPosition = t.anchoredPosition;
1322 }

◆ CopyValues< TKey, TValue >()

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

Definition at line 408 of file ClassExtension.cs.

409 {
410 TValue[] array = new TValue[dict.Keys.Count];
411 dict.Values.CopyTo(array, 0);
412 return array;
413 }

◆ CreateMold< T >()

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

Definition at line 1388 of file ClassExtension.cs.

1388 : Component
1389 {
1390 T result = null;
1391 for (int i = 0; i < c.transform.childCount; i++)
1392 {
1393 T component = c.transform.GetChild(i).GetComponent<T>();
1394 if ((bool)component && (name.IsEmpty() || name == component.name))
1395 {
1396 component.gameObject.SetActive(value: false);
1397 result = component;
1398 break;
1399 }
1400 }
1401 c.DestroyChildren();
1402 return result;
1403 }

◆ DestroyChildren()

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

Definition at line 1510 of file ClassExtension.cs.

1511 {
1512 if (!component || !component.transform)
1513 {
1514 Debug.LogWarning("DestroyChlidren:" + component);
1515 return;
1516 }
1517 for (int num = component.transform.childCount - 1; num >= 0; num--)
1518 {
1519 GameObject gameObject = component.transform.GetChild(num).gameObject;
1520 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1521 {
1522 UnityEngine.Object.DestroyImmediate(gameObject);
1523 }
1524 }
1525 }

References Debug.

◆ Distance()

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

Definition at line 1703 of file ClassExtension.cs.

1704 {
1705 return Vector3.Distance(t.position, pos);
1706 }

◆ Each< TValue >()

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

Definition at line 348 of file ClassExtension.cs.

349 {
350 for (int num = list.Count - 1; num >= 0; num--)
351 {
352 action(list[num]);
353 }
354 }

◆ Evalute()

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

Definition at line 857 of file ClassExtension.cs.

858 {
859 return array[(int)Mathf.Clamp((float)(array.Length - 1) * val, 0f, array.Length - 1)];
860 }

◆ Find()

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

Definition at line 1405 of file ClassExtension.cs.

1406 {
1407 return c.Find<Transform>(name);
1408 }

◆ Find< T >()

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

Definition at line 1410 of file ClassExtension.cs.

1410 : Component
1411 {
1412 if (recursive)
1413 {
1414 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1415 foreach (T val in componentsInChildren)
1416 {
1417 if (name == null || name == val.name)
1418 {
1419 return val;
1420 }
1421 }
1422 return null;
1423 }
1424 for (int j = 0; j < c.transform.childCount; j++)
1425 {
1426 T component = c.transform.GetChild(j).GetComponent<T>();
1427 if ((bool)component && (name == null || name == component.name))
1428 {
1429 return component;
1430 }
1431 }
1432 return null;
1433 }

◆ FindMax< T >()

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

Definition at line 626 of file ClassExtension.cs.

627 {
628 int num = int.MinValue;
629 T result = default(T);
630 foreach (T item in list)
631 {
632 int num2 = func(item);
633 if (num2 > num)
634 {
635 num = num2;
636 result = item;
637 }
638 }
639 return result;
640 }

References item.

◆ FindTagInParents()

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

Definition at line 1435 of file ClassExtension.cs.

1436 {
1437 Transform transform = c.transform;
1438 for (int i = 0; i < transform.childCount; i++)
1439 {
1440 Transform child = transform.GetChild(i);
1441 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1442 {
1443 return child.gameObject;
1444 }
1445 }
1446 if ((bool)transform.parent)
1447 {
1448 return transform.parent.FindTagInParents(tag, includeInactive);
1449 }
1450 return null;
1451 }

◆ FirstItem< TKey, TValue >()

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

Definition at line 517 of file ClassExtension.cs.

518 {
519 if (source == null)
520 {
521 return default(TValue);
522 }
523 return source[source.First().Key];
524 }

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

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

Definition at line 1997 of file ClassExtension.cs.

1998 {
1999 for (int num = items.Count - 1; num >= 0; num--)
2000 {
2001 action(items[num]);
2002 }
2003 }

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

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

Definition at line 2005 of file ClassExtension.cs.

2006 {
2007 int num = items.Count - 1;
2008 while (num >= 0 && !action(items[num]))
2009 {
2010 num--;
2011 }
2012 }

◆ FromInt2()

static float ClassExtension.FromInt2 ( this int  a)
inlinestatic

Definition at line 112 of file ClassExtension.cs.

113 {
114 return (float)a / 100f;
115 }

◆ FromInt3()

static float ClassExtension.FromInt3 ( this int  a)
inlinestatic

Definition at line 102 of file ClassExtension.cs.

103 {
104 return (float)a / 1000f;
105 }

◆ GetAnchor()

static RectPosition ClassExtension.GetAnchor ( this RectTransform  _rect)
inlinestatic

Definition at line 1628 of file ClassExtension.cs.

1629 {
1630 Vector3 position = _rect.position;
1631 int width = Screen.width;
1632 int height = Screen.height;
1633 bool flag = position.y > (float)height * 0.5f;
1634 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1635 {
1636 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1637 {
1638 return RectPosition.Center;
1639 }
1640 if (!flag)
1641 {
1642 return RectPosition.BottomCenter;
1643 }
1644 return RectPosition.TopCenter;
1645 }
1646 if (position.x < (float)width * 0.5f)
1647 {
1648 if (!flag)
1649 {
1650 return RectPosition.BottomLEFT;
1651 }
1652 return RectPosition.TopLEFT;
1653 }
1654 if (!flag)
1655 {
1656 return RectPosition.BottomRIGHT;
1657 }
1658 return RectPosition.TopRIGHT;
1659 }

◆ GetBit()

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

Definition at line 83 of file ClassExtension.cs.

84 {
85 return (pByte & (1 << bitNo)) != 0;
86 }

◆ GetComponentInChildrenExcludSelf< T >()

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

Definition at line 1453 of file ClassExtension.cs.

1453 : Component
1454 {
1455 for (int i = 0; i < c.childCount; i++)
1456 {
1457 T component = c.GetChild(i).GetComponent<T>();
1458 if ((bool)component)
1459 {
1460 return component;
1461 }
1462 }
1463 return null;
1464 }

◆ GetComponentInDirectChildren< T >()

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

Definition at line 1496 of file ClassExtension.cs.

1496 : Component
1497 {
1498 Transform transform = comp.transform;
1499 for (int i = 0; i < transform.childCount; i++)
1500 {
1501 T component = transform.GetChild(i).GetComponent<T>();
1502 if ((bool)component)
1503 {
1504 return component;
1505 }
1506 }
1507 return null;
1508 }

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

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

Definition at line 1481 of file ClassExtension.cs.

1481 : Component
1482 {
1483 List<T> list = new List<T>();
1484 Transform transform = comp.transform;
1485 for (int i = 0; i < transform.childCount; i++)
1486 {
1487 T component = transform.GetChild(i).GetComponent<T>();
1488 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1489 {
1490 list.Add(component);
1491 }
1492 }
1493 return list;
1494 }

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

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

Definition at line 1466 of file ClassExtension.cs.

1466 : Component
1467 {
1468 List<T> list = new List<T>();
1469 Transform transform = comp.transform;
1470 for (int i = 0; i < transform.childCount; i++)
1471 {
1472 T component = transform.GetChild(i).GetComponent<T>();
1473 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1474 {
1475 list.Add(component);
1476 }
1477 }
1478 return list;
1479 }

◆ GetField< T >()

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

Definition at line 236 of file ClassExtension.cs.

237 {
238 return (T)o.GetType().GetField(name).GetValue(o);
239 }

◆ GetForwardDiffPoint()

static float ClassExtension.GetForwardDiffPoint ( Vector2  forward)
inlinestaticprivate

Definition at line 1680 of file ClassExtension.cs.

1681 {
1682 if (object.Equals(forward, Vector2.up))
1683 {
1684 return 90f;
1685 }
1686 object.Equals(forward, Vector2.right);
1687 return 0f;
1688 }

References forward.

Referenced by LookAt2D().

◆ GetFullFileNameWithoutExtension() [1/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this FileInfo  fileInfo)
inlinestatic

Definition at line 992 of file ClassExtension.cs.

993 {
994 return fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name);
995 }

◆ GetFullFileNameWithoutExtension() [2/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this string  path)
inlinestatic

Definition at line 997 of file ClassExtension.cs.

998 {
999 return new FileInfo(path).GetFullFileNameWithoutExtension();
1000 }

◆ GetLastChild()

static Transform ClassExtension.GetLastChild ( this Transform  trans)
inlinestatic

Definition at line 1661 of file ClassExtension.cs.

1662 {
1663 return trans.GetChild(trans.childCount - 1);
1664 }

◆ GetList< T >()

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

Definition at line 604 of file ClassExtension.cs.

605 {
606 List<T> list = new List<T>();
607 foreach (object value in source.Values)
608 {
609 if (value is T)
610 {
611 list.Add((T)value);
612 }
613 }
614 return list;
615 }

◆ GetOrCreate< T >()

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

Definition at line 1300 of file ClassExtension.cs.

1300 : Component
1301 {
1302 T val = t.gameObject.GetComponent<T>();
1303 if (!val)
1304 {
1305 val = t.gameObject.AddComponent<T>();
1306 }
1307 return val;
1308 }

◆ GetOrCreate< TKey, TValue >()

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

Definition at line 390 of file ClassExtension.cs.

391 {
392 TValue val = dict.TryGetValue(key);
393 if (val == null)
394 {
395 val = ((func != null) ? func() : Activator.CreateInstance<TValue>());
396 dict.Add(key, val);
397 }
398 return val;
399 }

◆ GetProperty< T >()

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

Definition at line 246 of file ClassExtension.cs.

247 {
248 return (T)o.GetType().GetProperty(name).GetValue(o);
249 }

◆ GetRuntimeEventCount()

static int ClassExtension.GetRuntimeEventCount ( this UnityEventBase  unityEvent)
inlinestatic

Definition at line 2036 of file ClassExtension.cs.

2037 {
2038 Type typeFromHandle = typeof(UnityEventBase);
2039 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2040 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2041 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2042 Type type3 = typeof(List<>).MakeGenericType(type2);
2043 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2044 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2045 object value = field.GetValue(unityEvent);
2046 object value2 = field2.GetValue(value);
2047 return (int)type3.GetProperty("Count").GetValue(value2, null);
2048 }

◆ GetSelectable()

static Selectable ClassExtension.GetSelectable ( this GameObject  go)
inlinestatic

Definition at line 1346 of file ClassExtension.cs.

1347 {
1348 return go.GetComponentInChildren<Selectable>();
1349 }

◆ GetSpecialArticle()

static string ClassExtension.GetSpecialArticle ( string  a)
inlinestatic

Definition at line 1011 of file ClassExtension.cs.

1012 {
1013 if (a.ToLower() == "unicorn")
1014 {
1015 return "a ";
1016 }
1017 return null;
1018 }

Referenced by AddArticle().

◆ HasField< T >()

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

Definition at line 226 of file ClassExtension.cs.

227 {
228 FieldInfo field = o.GetType().GetField(name);
229 if (field != null)
230 {
231 return typeof(T).IsAssignableFrom(field.FieldType);
232 }
233 return false;
234 }

◆ HasTag()

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

Definition at line 957 of file ClassExtension.cs.

958 {
959 return s.Split(splitter).Contains(id);
960 }

◆ IndexOf()

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

Definition at line 310 of file ClassExtension.cs.

311 {
312 if (!go)
313 {
314 return -1;
315 }
316 for (int i = 0; i < list.Count; i++)
317 {
318 if (list[i].gameObject == go)
319 {
320 return i;
321 }
322 }
323 return -1;
324 }

◆ Instantiate< T >()

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

Definition at line 2028 of file ClassExtension.cs.

2028 : ScriptableObject
2029 {
2030 string name = s.name;
2031 T val = UnityEngine.Object.Instantiate(s);
2032 val.name = name;
2033 return val;
2034 }

◆ IsChildOf()

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

Definition at line 1370 of file ClassExtension.cs.

1371 {
1372 if (c.transform == root.transform)
1373 {
1374 return true;
1375 }
1376 if ((bool)c.transform.parent)
1377 {
1378 return c.transform.parent.gameObject.IsChildOf(root);
1379 }
1380 return false;
1381 }

◆ IsEmpty() [1/3]

static bool ClassExtension.IsEmpty ( this Array  array)
inlinestatic

Definition at line 301 of file ClassExtension.cs.

302 {
303 if (array != null)
304 {
305 return array.Length == 0;
306 }
307 return true;
308 }

◆ IsEmpty() [2/3]

static bool ClassExtension.IsEmpty ( this string  str)
inlinestatic

Definition at line 798 of file ClassExtension.cs.

799 {
800 if (str != null)
801 {
802 return str == "";
803 }
804 return true;
805 }

◆ IsEmpty() [3/3]

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

Definition at line 807 of file ClassExtension.cs.

808 {
809 if (str != null && !(str == ""))
810 {
811 return str;
812 }
813 return defaultStr;
814 }

◆ IsInteractable()

static bool ClassExtension.IsInteractable ( this GameObject  obj)
inlinestatic

Definition at line 1360 of file ClassExtension.cs.

1361 {
1362 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1363 if ((bool)selectable)
1364 {
1365 return selectable.interactable;
1366 }
1367 return false;
1368 }

◆ IsMouseOver()

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

Definition at line 1527 of file ClassExtension.cs.

1528 {
1529 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1530 }

◆ IsNull()

static bool ClassExtension.IsNull ( this object  o)
inlinestatic

Definition at line 130 of file ClassExtension.cs.

131 {
132 return o == null;
133 }

◆ IsOn()

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

Definition at line 135 of file ClassExtension.cs.

136 {
137 BitArray32 bitArray = default(BitArray32);
138 bitArray.SetInt(data);
139 return bitArray[digit];
140 }
void SetInt(int i)
Definition: BitArray32.cs:89

References BitArray32.SetInt().

◆ IsPrefab()

static bool ClassExtension.IsPrefab ( this Component  c)
inlinestatic

Definition at line 1383 of file ClassExtension.cs.

1384 {
1385 return c.gameObject.scene.name == null;
1386 }

◆ lang() [1/2]

static string ClassExtension.lang ( this string  s)
inlinestatic

Definition at line 20 of file ClassExtension.cs.

21 {
22 return Lang.Get(s);
23 }
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 31 of file ClassExtension.cs.

32 {
33 return Lang.Parse(s, ref1, ref2, ref3, ref4, ref5);
34 }
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 41 of file ClassExtension.cs.

42 {
43 return Lang.Game.Get(s);
44 }
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 46 of file ClassExtension.cs.

47 {
48 return Lang.Game.Parse(s, ref1, ref2, ref3, ref4);
49 }
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 36 of file ClassExtension.cs.

37 {
38 return Lang.GetList(s);
39 }

References Lang.GetList().

◆ langPlural()

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

Definition at line 25 of file ClassExtension.cs.

26 {
27 string text = Lang.Get(s);
28 return Lang.Parse((i <= 1 || !Lang.setting.pluralize) ? text : pluralizer.Pluralize(text), i.ToString() ?? "");
29 }
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 526 of file ClassExtension.cs.

527 {
528 if (source.Count != 0)
529 {
530 return source[source.Count - 1];
531 }
532 return default(TValue);
533 }

◆ LookAt2D() [1/2]

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

Definition at line 1690 of file ClassExtension.cs.

1691 {
1692 self.LookAt2D(target.position, forward);
1693 }

References forward.

◆ LookAt2D() [2/2]

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

Definition at line 1695 of file ClassExtension.cs.

1696 {
1697 float forwardDiffPoint = GetForwardDiffPoint(forward);
1698 Vector3 vector = target - self.position;
1699 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1700 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1701 }
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 1126 of file ClassExtension.cs.

1127 {
1128 for (int i = 0; i < sels.Count; i++)
1129 {
1130 Selectable selectable = sels[i];
1131 Selectable selectable2 = sels[0];
1132 Navigation navigation = selectable.navigation;
1133 if (horizonal)
1134 {
1135 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1136 }
1137 if (asGroup)
1138 {
1139 for (int j = i + 1; j < sels.Count; j++)
1140 {
1141 if (sels[j].transform.position.y < selectable.transform.position.y)
1142 {
1143 selectable2 = sels[j];
1144 break;
1145 }
1146 }
1147 }
1148 else
1149 {
1150 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1151 }
1152 if (vertical)
1153 {
1154 navigation.selectOnDown = selectable2;
1155 }
1156 selectable.navigation = navigation;
1157 }
1158 for (int num = sels.Count - 1; num >= 0; num--)
1159 {
1160 Selectable selectable3 = sels[num];
1161 Selectable selectable4 = sels[sels.Count - 1];
1162 Navigation navigation2 = selectable3.navigation;
1163 if (horizonal)
1164 {
1165 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1166 }
1167 if (asGroup)
1168 {
1169 int num2 = sels.Count - 1;
1170 for (int num3 = num - 1; num3 >= 0; num3--)
1171 {
1172 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1173 {
1174 num2 = num3;
1175 break;
1176 }
1177 }
1178 int num4 = num2;
1179 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1180 {
1181 selectable4 = sels[num4];
1182 num4--;
1183 }
1184 }
1185 else
1186 {
1187 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1188 }
1189 if (vertical)
1190 {
1191 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1192 }
1193 navigation2.mode = Navigation.Mode.Explicit;
1194 selectable3.navigation = navigation2;
1195 }
1196 }

◆ LoopSelectable() [2/2]

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

Definition at line 1198 of file ClassExtension.cs.

1199 {
1200 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1201 for (int num = list.Count - 1; num >= 0; num--)
1202 {
1203 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1204 {
1205 list.RemoveAt(num);
1206 }
1207 }
1208 list.LoopSelectable(vertical, horizonal, asGroup);
1209 }

◆ LoopTail< T >()

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

Definition at line 1078 of file ClassExtension.cs.

1078 : Selectable
1079 {
1080 if (list.Count > 1)
1081 {
1082 Navigation navigation = list[0].navigation;
1083 Navigation navigation2 = list[list.Count - 1].navigation;
1084 if (vertical)
1085 {
1086 navigation.selectOnUp = list[list.Count - 1];
1087 navigation2.selectOnDown = list[0];
1088 }
1089 else
1090 {
1091 navigation.selectOnLeft = list[list.Count - 1];
1092 navigation2.selectOnRight = list[0];
1093 }
1094 list[0].navigation = navigation;
1095 list[list.Count - 1].navigation = navigation2;
1096 }
1097 }

◆ Minimum()

static int ClassExtension.Minimum ( this int  i)
inlinestatic

Definition at line 117 of file ClassExtension.cs.

118 {
119 if (i != 0)
120 {
121 if (i <= 0)
122 {
123 return -1;
124 }
125 return 1;
126 }
127 return 0;
128 }

◆ Move< TValue >()

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

Definition at line 326 of file ClassExtension.cs.

327 {
328 int num = list.IndexOf(target);
329 int num2 = num + a;
330 if (num2 < 0)
331 {
332 num2 = list.Count - 1;
333 }
334 if (num2 >= list.Count)
335 {
336 num2 = 0;
337 }
338 list.Remove(target);
339 list.Insert(num2, target);
340 return list[num];
341 }

◆ Multiply()

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

Definition at line 1234 of file ClassExtension.cs.

1235 {
1236 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1237 }

References Color.

◆ NextEnum< T >()

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

Definition at line 162 of file ClassExtension.cs.

162 : struct
163 {
164 return ((T[])Enum.GetValues(src.GetType())).NextItem(src);
165 }

◆ NextIndex< TValue >()

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

Definition at line 549 of file ClassExtension.cs.

550 {
551 if (val == null)
552 {
553 return 0;
554 }
555 int num = source.IndexOf(val) + 1;
556 if (num >= source.Count)
557 {
558 num = 0;
559 }
560 return num;
561 }

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

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

Definition at line 535 of file ClassExtension.cs.

536 {
537 index++;
538 if (index >= source.Count)
539 {
540 index = 0;
541 }
542 if (source.Count != 0)
543 {
544 return source[index];
545 }
546 return default(TValue);
547 }

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

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

Definition at line 563 of file ClassExtension.cs.

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

◆ Parentheses()

static string ClassExtension.Parentheses ( this string  str)
inlinestatic

Definition at line 51 of file ClassExtension.cs.

52 {
53 return "(" + str + ")";
54 }

◆ Pluralize()

static string ClassExtension.Pluralize ( string  s)
inlinestatic

Definition at line 1002 of file ClassExtension.cs.

1003 {
1004 if (s == "talisman")
1005 {
1006 return "talismans";
1007 }
1008 return pluralizer.Pluralize(s);
1009 }

References pluralizer.

Referenced by AddArticle().

◆ Plus()

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

Definition at line 1708 of file ClassExtension.cs.

1709 {
1710 v.x += v2.x;
1711 v.y += v2.y;
1712 return v;
1713 }

◆ PlusX()

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

Definition at line 1727 of file ClassExtension.cs.

1728 {
1729 v.x += a;
1730 return v;
1731 }

◆ PlusY()

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

Definition at line 1733 of file ClassExtension.cs.

1734 {
1735 v.y += a;
1736 return v;
1737 }

◆ PlusZ()

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

Definition at line 1739 of file ClassExtension.cs.

1740 {
1741 v.z += a;
1742 return v;
1743 }

◆ PrevEnum< T >()

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

Definition at line 167 of file ClassExtension.cs.

167 : struct
168 {
169 return ((T[])Enum.GetValues(src.GetType())).PrevItem(src);
170 }

◆ PrevItem< TValue >()

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

Definition at line 577 of file ClassExtension.cs.

578 {
579 int num = source.IndexOf(val) - 1;
580 if (num < 0)
581 {
582 num = source.Count - 1;
583 }
584 if (source.Count != 0)
585 {
586 return source[num];
587 }
588 return default(TValue);
589 }

◆ Random()

static Vector3 ClassExtension.Random ( this Vector3  v)
inlinestatic

Definition at line 2023 of file ClassExtension.cs.

2024 {
2025 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2026 }
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 415 of file ClassExtension.cs.

416 {
417 int num = ie.Count();
418 if (num == 0)
419 {
420 return default(T);
421 }
422 return ie.ElementAt(Rand.rnd(num));
423 }
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 425 of file ClassExtension.cs.

426 {
427 if (source.Count != 0)
428 {
429 return source.ElementAt(Rand.rnd(source.Count)).Value;
430 }
431 return default(TValue);
432 }

References Rand.rnd().

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

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

Definition at line 434 of file ClassExtension.cs.

435 {
436 if (source.Count != 0)
437 {
438 return source[Rand.rnd(source.Count)];
439 }
440 return default(TValue);
441 }

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

468 {
469 for (int i = 0; i < 100; i++)
470 {
471 TValue val = source[Rand.rnd(source.Count)];
472 if (funcValid(val))
473 {
474 return val;
475 }
476 }
477 return defaultValue;
478 }

References Rand.rnd().

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

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

Definition at line 448 of file ClassExtension.cs.

449 {
450 if (source.Count > 1)
451 {
452 int num;
453 do
454 {
455 num = Rand.rnd(source.Count);
456 }
457 while (num == exclude);
458 return source[num];
459 }
460 if (source.Count == 1)
461 {
462 return source[0];
463 }
464 return default(TValue);
465 }

References Rand.rnd().

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

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

Definition at line 443 of file ClassExtension.cs.

444 {
445 return source.RandomItem(source.IndexOf(exclude));
446 }

◆ RandomItemWeighted< TValue >()

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

Definition at line 480 of file ClassExtension.cs.

481 {
482 if (source.Count == 0)
483 {
484 return default(TValue);
485 }
486 if (source.Count == 1)
487 {
488 return source[0];
489 }
490 float num = 0f;
491 foreach (TValue item in source)
492 {
493 num += getWeight(item);
494 }
495 float num2 = Rand.Range(0f, num);
496 num = 0f;
497 foreach (TValue item2 in source)
498 {
499 num += getWeight(item2);
500 if (num2 < num)
501 {
502 return item2;
503 }
504 }
505 return source.First();
506 }

References item, and Rand.Range().

◆ RebuildLayout()

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

Definition at line 1532 of file ClassExtension.cs.

1533 {
1534 if (recursive)
1535 {
1536 foreach (Transform item in c.transform)
1537 {
1538 if (item is RectTransform)
1539 {
1540 item.RebuildLayout(recursive: true);
1541 }
1542 }
1543 }
1544 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1545 }

References item.

◆ RebuildLayoutTo()

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

Definition at line 1556 of file ClassExtension.cs.

1557 {
1558 c.RebuildLayout();
1559 if (!(c == target) && (bool)c.transform.parent)
1560 {
1561 c.transform.parent.RebuildLayoutTo(target);
1562 }
1563 }

◆ RebuildLayoutTo< T >()

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

Definition at line 1547 of file ClassExtension.cs.

1547 : Component
1548 {
1549 c.RebuildLayout();
1550 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1551 {
1552 c.transform.parent.RebuildLayoutTo<T>();
1553 }
1554 }

◆ Rect()

static RectTransform ClassExtension.Rect ( this Component  c)
inlinestatic

Definition at line 1310 of file ClassExtension.cs.

1311 {
1312 return c.transform as RectTransform;
1313 }

◆ Remainder< TValue >()

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

Definition at line 508 of file ClassExtension.cs.

509 {
510 if (source.Count != 0)
511 {
512 return source[divider % source.Count];
513 }
514 return default(TValue);
515 }

◆ RemoveAllTags()

static string ClassExtension.RemoveAllTags ( this string  text)
inlinestatic

Definition at line 669 of file ClassExtension.cs.

670 {
671 if (string.IsNullOrEmpty(text))
672 {
673 return text;
674 }
675 return Regex.Replace(text, "<.*?>", "");
676 }

◆ RemoveNewline()

static string ClassExtension.RemoveNewline ( this string  text)
inlinestatic

Definition at line 660 of file ClassExtension.cs.

661 {
662 if (string.IsNullOrEmpty(text))
663 {
664 return text;
665 }
666 return text.Replace("\r", "").Replace("\n", "");
667 }

◆ RemoveTag()

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

Definition at line 977 of file ClassExtension.cs.

978 {
979 string[] array = s.Split(splitter);
980 s = "";
981 string[] array2 = array;
982 foreach (string text in array2)
983 {
984 if (!(text == id))
985 {
986 s.AddTag(text, splitter);
987 }
988 }
989 return s;
990 }

◆ Repeat()

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

Definition at line 773 of file ClassExtension.cs.

774 {
775 StringBuilder stringBuilder = new StringBuilder();
776 for (int i = 0; i < Mathf.Abs(count); i++)
777 {
778 stringBuilder.Append(str);
779 }
780 return stringBuilder.ToString();
781 }

◆ Set< T1, T2 >()

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

Definition at line 642 of file ClassExtension.cs.

643 {
644 dic.Clear();
645 foreach (KeyValuePair<T1, T2> item in from)
646 {
647 dic[item.Key] = item.Value;
648 }
649 }

References item.

◆ SetActive() [1/2]

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

Definition at line 1329 of file ClassExtension.cs.

1330 {
1331 if (c.gameObject.activeSelf != enable)
1332 {
1333 c.gameObject.SetActive(enable);
1334 }
1335 }

Referenced by ContentQuest.RefreshTrackButtons().

◆ SetActive() [2/2]

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

Definition at line 1337 of file ClassExtension.cs.

1338 {
1339 if (c.gameObject.activeSelf != enable)
1340 {
1341 c.gameObject.SetActive(enable);
1342 onChangeState(enable);
1343 }
1344 }

◆ SetAlpha() [1/4]

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

Definition at line 1228 of file ClassExtension.cs.

1229 {
1230 c.a = a;
1231 return c;
1232 }

◆ SetAlpha() [2/4]

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

Definition at line 1218 of file ClassExtension.cs.

1219 {
1220 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1221 }

References Color.

◆ SetAlpha() [3/4]

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

Definition at line 1223 of file ClassExtension.cs.

1224 {
1225 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1226 }

References Color.

◆ SetAlpha() [4/4]

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

Definition at line 1267 of file ClassExtension.cs.

1268 {
1269 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1270 }

References Color.

◆ SetAnchor() [1/2]

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

Definition at line 1621 of file ClassExtension.cs.

1622 {
1623 Vector3 position = _rect.position;
1624 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1625 _rect.position = position;
1626 }

◆ SetAnchor() [2/2]

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

Definition at line 1581 of file ClassExtension.cs.

1582 {
1583 r.anchorMin = new Vector2(minX, minY);
1584 r.anchorMax = new Vector2(maxX, maxY);
1585 }

◆ SetBit()

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

Definition at line 88 of file ClassExtension.cs.

89 {
90 if (!value)
91 {
92 return Convert.ToByte(pByte & ~(1 << bitNo));
93 }
94 return Convert.ToByte(pByte | (1 << bitNo));
95 }

◆ SetEulerAngles()

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

Definition at line 1889 of file ClassExtension.cs.

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

References vector3.

◆ SetEulerAnglesX()

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

Definition at line 1895 of file ClassExtension.cs.

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

References vector3.

◆ SetEulerAnglesY()

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

Definition at line 1901 of file ClassExtension.cs.

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

References vector3.

◆ SetEulerAnglesZ()

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

Definition at line 1907 of file ClassExtension.cs.

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

References vector3.

◆ SetField< T >()

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

Definition at line 241 of file ClassExtension.cs.

242 {
243 o.GetType().GetField(name).SetValue(o, value);
244 }

◆ SetLayerRecursively()

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

Definition at line 1351 of file ClassExtension.cs.

1352 {
1353 obj.layer = layer;
1354 foreach (Transform item in obj.transform)
1355 {
1356 item.gameObject.SetLayerRecursively(layer);
1357 }
1358 }

References item.

◆ SetListener()

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

Definition at line 1258 of file ClassExtension.cs.

1259 {
1260 e.RemoveAllListeners();
1261 e.AddListener(delegate
1262 {
1263 action();
1264 });
1265 }

References Button.

◆ SetLocalEulerAngles()

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

Definition at line 1937 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalEulerAnglesX()

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

Definition at line 1943 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalEulerAnglesY()

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

Definition at line 1949 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalEulerAnglesZ()

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

Definition at line 1955 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPosition()

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

Definition at line 1793 of file ClassExtension.cs.

1794 {
1795 vector3.Set(x, y, z);
1796 transform.localPosition = vector3;
1797 }

References vector3.

◆ SetLocalPositionX()

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

Definition at line 1799 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPositionY()

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

Definition at line 1805 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPositionZ()

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

Definition at line 1811 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScale()

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

Definition at line 1841 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleX()

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

Definition at line 1847 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleY()

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

Definition at line 1853 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleZ()

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

Definition at line 1859 of file ClassExtension.cs.

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

References vector3.

◆ SetNavigation()

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

Definition at line 1099 of file ClassExtension.cs.

1100 {
1101 if (!a || !b)
1102 {
1103 return;
1104 }
1105 Selectable component = a.GetComponent<Selectable>();
1106 Selectable component2 = b.GetComponent<Selectable>();
1107 if ((bool)component && (bool)component2)
1108 {
1109 Navigation navigation = component.navigation;
1110 Navigation navigation2 = component2.navigation;
1111 if (vertical)
1112 {
1113 navigation.selectOnUp = component2;
1114 navigation2.selectOnDown = component;
1115 }
1116 else
1117 {
1118 navigation.selectOnLeft = component2;
1119 navigation2.selectOnRight = component;
1120 }
1121 component.navigation = navigation;
1122 component2.navigation = navigation2;
1123 }
1124 }

◆ SetOnClick()

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

Definition at line 1249 of file ClassExtension.cs.

1250 {
1251 b.onClick.RemoveAllListeners();
1252 b.onClick.AddListener(delegate
1253 {
1254 action();
1255 });
1256 }

◆ SetPivot()

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

Definition at line 1576 of file ClassExtension.cs.

1577 {
1578 r.pivot = new Vector2(x, y);
1579 }

◆ SetPosition()

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

Definition at line 1745 of file ClassExtension.cs.

1746 {
1747 vector3.Set(x, y, z);
1748 transform.position = vector3;
1749 }

References vector3.

◆ SetPositionX()

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

Definition at line 1751 of file ClassExtension.cs.

1752 {
1753 vector3.Set(x, transform.position.y, transform.position.z);
1754 transform.position = vector3;
1755 }

References vector3.

◆ SetPositionY()

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

Definition at line 1757 of file ClassExtension.cs.

1758 {
1759 vector3.Set(transform.position.x, y, transform.position.z);
1760 transform.position = vector3;
1761 }

References vector3.

◆ SetPositionZ()

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

Definition at line 1763 of file ClassExtension.cs.

1764 {
1765 vector3.Set(transform.position.x, transform.position.y, z);
1766 transform.position = vector3;
1767 }

References vector3.

◆ SetProperty< T >()

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

Definition at line 251 of file ClassExtension.cs.

252 {
253 o.GetType().GetProperty(name).SetValue(o, value);
254 }

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

1566 {
1567 r.SetPivot(pivotX, pivotY);
1568 r.SetAnchor(minX, minY, maxX, maxY);
1569 if (w != -1f)
1570 {
1571 r.sizeDelta = new Vector2(w, h);
1572 }
1573 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1574 }

◆ SetScale()

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

Definition at line 1671 of file ClassExtension.cs.

1672 {
1673 float x = renderer.bounds.size.x;
1674 float y = renderer.bounds.size.y;
1675 float x2 = size / x;
1676 float y2 = size / y;
1677 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1678 }

◆ SetSlider() [1/2]

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

Definition at line 1272 of file ClassExtension.cs.

1273 {
1274 slider.SetSlider(value, action, -1, -1, notify);
1275 }

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

1278 {
1279 slider.onValueChanged.RemoveAllListeners();
1280 slider.onValueChanged.AddListener(delegate(float a)
1281 {
1282 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1283 });
1284 if (min != -1)
1285 {
1286 slider.minValue = min;
1287 slider.maxValue = max;
1288 }
1289 if (notify)
1290 {
1291 slider.value = value;
1292 }
1293 else
1294 {
1295 slider.SetValueWithoutNotify(value);
1296 }
1297 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1298 }

◆ SetTag()

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

Definition at line 962 of file ClassExtension.cs.

963 {
964 s = ((!enable) ? s.RemoveTag(id, splitter) : s.AddTag(id, splitter));
965 return s;
966 }

◆ SetY()

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

Definition at line 1721 of file ClassExtension.cs.

1722 {
1723 v.y = a;
1724 return v;
1725 }

◆ SetZ()

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

Definition at line 1715 of file ClassExtension.cs.

1716 {
1717 v.z = a;
1718 return v;
1719 }

◆ Shuffle< TValue >()

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

Definition at line 356 of file ClassExtension.cs.

357 {
358 int num = list.Count;
359 while (num > 1)
360 {
361 int index = Rand._random.Next(num);
362 num--;
363 TValue value = list[num];
364 list[num] = list[index];
365 list[index] = value;
366 }
367 return list;
368 }
static Random _random
Definition: Rand.cs:9

References Rand._random.

◆ Sort< T >()

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

Definition at line 256 of file ClassExtension.cs.

257 {
258 if (list is List<T>)
259 {
260 ((List<T>)list).Sort(comparison);
261 return;
262 }
263 List<T> list2 = new List<T>(list);
264 list2.Sort(comparison);
265 for (int i = 0; i < list.Count; i++)
266 {
267 list[i] = list2[i];
268 }
269 }

◆ SplitByNewline()

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

Definition at line 651 of file ClassExtension.cs.

652 {
653 if (string.IsNullOrEmpty(text))
654 {
655 return new string[0];
656 }
657 return text.Split(new string[3] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
658 }

◆ SplitNewline()

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

Definition at line 836 of file ClassExtension.cs.

837 {
838 return str.Split(Environment.NewLine.ToCharArray());
839 }

◆ SplitToInts()

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

Definition at line 825 of file ClassExtension.cs.

826 {
827 string[] array = str.Split(separator);
828 int[] array2 = new int[array.Length];
829 for (int i = 0; i < array.Length; i++)
830 {
831 array2[i] = int.Parse(array[i]);
832 }
833 return array2;
834 }

◆ StripBrackets()

static string ClassExtension.StripBrackets ( this string  str)
inlinestatic

Definition at line 783 of file ClassExtension.cs.

784 {
785 HashSet<char> brackets = new HashSet<char> { '"', '「', '」', '“', '”' };
786 return string.Concat(str.Where((char c) => !brackets.Contains(c)));
787 }

◆ StripLastPun()

static string ClassExtension.StripLastPun ( this string  str)
inlinestatic

Definition at line 737 of file ClassExtension.cs.

738 {
739 if (str != null)
740 {
741 return str.TrimEnd(Lang.words.period);
742 }
743 return str;
744 }
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 746 of file ClassExtension.cs.

747 {
748 StringBuilder stringBuilder = new StringBuilder();
749 foreach (char c in str)
750 {
751 if (c == Lang.words.comma)
752 {
753 if (stripComma)
754 {
755 if (insertSpaceForComma)
756 {
757 stringBuilder.Append('\u3000');
758 }
759 }
760 else
761 {
762 stringBuilder.Append(c);
763 }
764 }
765 else if (c != Lang.words.period)
766 {
767 stringBuilder.Append(c);
768 }
769 }
770 return stringBuilder.ToString();
771 }
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 1239 of file ClassExtension.cs.

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

References $.

◆ TagColor() [1/2]

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

Definition at line 942 of file ClassExtension.cs.

943 {
944 return "<color=" + c.ToHex() + ">" + s + "</color>";
945 }

◆ TagColor() [2/2]

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

Definition at line 937 of file ClassExtension.cs.

938 {
939 return s + "<color=" + c.ToHex() + ">" + txt + "</color>";
940 }

◆ TagSize() [1/2]

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

Definition at line 952 of file ClassExtension.cs.

953 {
954 return "<size=" + size + ">" + s + "</size>";
955 }

◆ TagSize() [2/2]

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

Definition at line 947 of file ClassExtension.cs.

948 {
949 return s + "<size=" + size + ">" + txt + "</size>";
950 }

◆ ToBytes()

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

Definition at line 76 of file ClassExtension.cs.

77 {
78 byte[] array = new byte[(bits.Length - 1) / 8 + 1];
79 bits.CopyTo(array, 0);
80 return array;
81 }

◆ ToColor()

static Color ClassExtension.ToColor ( this string  s)
inlinestatic

Definition at line 1211 of file ClassExtension.cs.

1212 {
1213 Color color = Color.white;
1214 ColorUtility.TryParseHtmlString("#" + s, out color);
1215 return color;
1216 }

References Color.

◆ ToDictionary< T >()

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

Definition at line 617 of file ClassExtension.cs.

618 {
619 dic = new Dictionary<string, T>();
620 for (int i = 0; i < list.Count; i++)
621 {
622 dic.Add(list[i].name, list[i].value);
623 }
624 }

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

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

Definition at line 142 of file ClassExtension.cs.

143 {
144 return (T)Enum.ToObject(typeof(T), value);
145 }

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

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

Definition at line 147 of file ClassExtension.cs.

148 {
149 return (T)Enum.ToObject(typeof(T), value);
150 }

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

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

Definition at line 152 of file ClassExtension.cs.

153 {
154 return (T)Enum.Parse(typeof(T), value, ignoreCase);
155 }

◆ ToField< T >()

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

Definition at line 221 of file ClassExtension.cs.

222 {
223 return (T)o.GetType().GetField(s).GetValue(o);
224 }

◆ ToFloat()

static float ClassExtension.ToFloat ( this string  str)
inlinestatic

Definition at line 718 of file ClassExtension.cs.

719 {
720 float result = 0f;
721 try
722 {
723 if (!float.TryParse(str, out result))
724 {
725 Debug.Log("exception: ToFlat1" + str);
726 result = 1f;
727 }
728 }
729 catch
730 {
731 Debug.Log("exception: ToFlat2" + str);
732 result = 1f;
733 }
734 return result;
735 }

References Debug.

◆ ToFormat() [1/2]

static string ClassExtension.ToFormat ( this int  a)
inlinestatic

Definition at line 905 of file ClassExtension.cs.

906 {
907 return $"{a:#,0}";
908 }

References $.

◆ ToFormat() [2/2]

static string ClassExtension.ToFormat ( this long  a)
inlinestatic

Definition at line 910 of file ClassExtension.cs.

911 {
912 return $"{a:#,0}";
913 }

References $.

◆ ToggleActive()

static void ClassExtension.ToggleActive ( this Component  c)
inlinestatic

Definition at line 1324 of file ClassExtension.cs.

1325 {
1326 c.SetActive(!c.gameObject.activeSelf);
1327 }

◆ ToggleKeyword()

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

Definition at line 1985 of file ClassExtension.cs.

1986 {
1987 if (enable)
1988 {
1989 m.EnableKeyword(id);
1990 }
1991 else
1992 {
1993 m.DisableKeyword(id);
1994 }
1995 }

◆ ToHex()

static string ClassExtension.ToHex ( this Color  c)
inlinestatic

Definition at line 1244 of file ClassExtension.cs.

1245 {
1246 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1247 }

References $.

◆ ToInt() [1/2]

static int ClassExtension.ToInt ( this string  str)
inlinestatic

Definition at line 700 of file ClassExtension.cs.

701 {
702 if (int.TryParse(str, out var result))
703 {
704 return result;
705 }
706 return 0;
707 }

◆ ToInt() [2/2]

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

Definition at line 689 of file ClassExtension.cs.

690 {
691 FieldInfo field = type.GetField(str, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
692 if (field == null)
693 {
694 Debug.LogError("Field is null:" + str + "/" + type);
695 return -1;
696 }
697 return (int)field.GetValue(null);
698 }

References Debug.

◆ ToInt2()

static int ClassExtension.ToInt2 ( this float  a)
inlinestatic

Definition at line 107 of file ClassExtension.cs.

108 {
109 return (int)(a * 100f);
110 }

◆ ToInt3()

static int ClassExtension.ToInt3 ( this float  a)
inlinestatic

Definition at line 97 of file ClassExtension.cs.

98 {
99 return (int)(a * 1000f);
100 }

◆ ToInt< T >()

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

Definition at line 684 of file ClassExtension.cs.

685 {
686 return str.ToInt(typeof(T));
687 }

◆ ToLong()

static long ClassExtension.ToLong ( this string  str)
inlinestatic

Definition at line 709 of file ClassExtension.cs.

710 {
711 if (long.TryParse(str, out var result))
712 {
713 return result;
714 }
715 return 0L;
716 }

◆ ToShortNumber()

static string ClassExtension.ToShortNumber ( this int  a)
inlinestatic

Definition at line 862 of file ClassExtension.cs.

863 {
864 if (a < 0)
865 {
866 string text;
867 if (a > -1000000)
868 {
869 if (a <= -1000)
870 {
871 return a / 1000 + "K";
872 }
873 text = a.ToString();
874 if (text == null)
875 {
876 return "";
877 }
878 }
879 else
880 {
881 text = a / 1000000 + "M";
882 }
883 return text;
884 }
885 string text2;
886 if (a < 1000000)
887 {
888 if (a >= 1000)
889 {
890 return a / 1000 + "K";
891 }
892 text2 = a.ToString();
893 if (text2 == null)
894 {
895 return "";
896 }
897 }
898 else
899 {
900 text2 = a / 1000000 + "M";
901 }
902 return text2;
903 }

◆ ToText()

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

Definition at line 915 of file ClassExtension.cs.

916 {
917 object obj;
918 if (!(a == 0 && skipIfZero))
919 {
920 if (a >= 0)
921 {
922 return "+" + a;
923 }
924 obj = a.ToString();
925 if (obj == null)
926 {
927 return "";
928 }
929 }
930 else
931 {
932 obj = "";
933 }
934 return (string)obj;
935 }

◆ ToTitleCase()

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

Definition at line 1051 of file ClassExtension.cs.

1052 {
1053 if (!Lang.setting.capitalize)
1054 {
1055 return s;
1056 }
1057 char[] array = s.ToCharArray();
1058 bool flag = true;
1059 for (int i = 0; i < array.Length; i++)
1060 {
1061 if (flag)
1062 {
1063 array[i] = char.ToUpper(array[i]);
1064 flag = false;
1065 }
1066 if (!wholeText)
1067 {
1068 break;
1069 }
1070 if (array[i] == ' ')
1071 {
1072 flag = true;
1073 }
1074 }
1075 return new string(array);
1076 }
bool capitalize
Definition: LangSetting.cs:34

References LangSetting.capitalize, and Lang.setting.

◆ ToType()

static Type ClassExtension.ToType ( this string  value)
inlinestatic

Definition at line 157 of file ClassExtension.cs.

158 {
159 return Type.GetType("Elona." + value + ", Assembly-CSharp");
160 }

◆ ToVector2()

static Vector2 ClassExtension.ToVector2 ( this Vector3  self)
inlinestatic

Definition at line 1666 of file ClassExtension.cs.

1667 {
1668 return new Vector2(self.x, self.z);
1669 }

◆ TrimNewLines()

static string ClassExtension.TrimNewLines ( this string  text)
inlinestatic

Definition at line 816 of file ClassExtension.cs.

817 {
818 while (text.EndsWith(Environment.NewLine))
819 {
820 text = text.Substring(0, text.Length - Environment.NewLine.Length);
821 }
822 return text;
823 }

◆ TryAddExtension()

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

Definition at line 789 of file ClassExtension.cs.

790 {
791 if (!s.Contains("." + ext))
792 {
793 return s + "." + ext;
794 }
795 return s;
796 }

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

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

Definition at line 292 of file ClassExtension.cs.

293 {
294 if (index >= array.Count)
295 {
296 return default(TValue);
297 }
298 return array[index];
299 }

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

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

Definition at line 271 of file ClassExtension.cs.

272 {
273 if (array.Count != 0)
274 {
275 if (index >= array.Count)
276 {
277 if (defIndex != -1)
278 {
279 if (array.Count <= defIndex)
280 {
281 return array[Mathf.Max(0, array.Count - 1)];
282 }
283 return array[defIndex];
284 }
285 return array[Mathf.Max(0, array.Count - 1)];
286 }
287 return array[Math.Max(0, index)];
288 }
289 return default(TValue);
290 }

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

381 {
382 TValue value = default(TValue);
383 if (key != null && source.TryGetValue(key, out value))
384 {
385 return value;
386 }
387 return source[key_fallback];
388 }

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

371 {
372 TValue value = default(TValue);
373 if (key != null && source.TryGetValue(key, out value))
374 {
375 return value;
376 }
377 return fallback;
378 }

◆ Within() [1/2]

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

Definition at line 181 of file ClassExtension.cs.

182 {
183 if (v - v2 >= range)
184 {
185 return v - v2 < -range;
186 }
187 return true;
188 }

◆ Within() [2/2]

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

Definition at line 172 of file ClassExtension.cs.

173 {
174 if (v - v2 >= range)
175 {
176 return v - v2 < -range;
177 }
178 return true;
179 }

Member Data Documentation

◆ pluralizer

IPluralize ClassExtension.pluralizer = new Pluralizer()
static

Definition at line 18 of file ClassExtension.cs.

Referenced by langPlural(), and Pluralize().

◆ vector3


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