Elin Decompiled Documentation EA 23.356.1 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 string ToSentenceCase (this string s)
 
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 1664 of file ClassExtension.cs.

1665 {
1666 switch (anchor)
1667 {
1668 case RectPosition.TopCenter:
1669 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1670 break;
1671 case RectPosition.BottomCenter:
1672 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1673 break;
1674 case RectPosition.TopLEFT:
1675 _rect.SetAnchor(0f, 1f, 0f, 1f);
1676 break;
1677 case RectPosition.TopRIGHT:
1678 _rect.SetAnchor(1f, 1f, 1f, 1f);
1679 break;
1680 case RectPosition.BottomLEFT:
1681 _rect.SetAnchor(0f, 0f, 0f, 0f);
1682 break;
1683 case RectPosition.BottomRIGHT:
1684 _rect.SetAnchor(1f, 0f, 1f, 0f);
1685 break;
1686 case RectPosition.Left:
1687 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1688 break;
1689 case RectPosition.Right:
1690 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1691 break;
1692 default:
1693 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1694 break;
1695 }
1696 }
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 1990 of file ClassExtension.cs.

1991 {
1992 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1993 transform.eulerAngles = vector3;
1994 }
static Vector3 vector3

References vector3.

◆ AddEulerAnglesX()

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

Definition at line 1996 of file ClassExtension.cs.

1997 {
1998 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
1999 transform.eulerAngles = vector3;
2000 }

References vector3.

◆ AddEulerAnglesY()

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

Definition at line 2002 of file ClassExtension.cs.

2003 {
2004 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
2005 transform.eulerAngles = vector3;
2006 }

References vector3.

◆ AddEulerAnglesZ()

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

Definition at line 2008 of file ClassExtension.cs.

2009 {
2010 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
2011 transform.eulerAngles = vector3;
2012 }

References vector3.

◆ AddLocalEulerAngles()

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

Definition at line 2038 of file ClassExtension.cs.

2039 {
2040 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
2041 transform.localEulerAngles = vector3;
2042 }

References vector3.

◆ AddLocalEulerAnglesX()

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

Definition at line 2044 of file ClassExtension.cs.

2045 {
2046 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
2047 transform.localEulerAngles = vector3;
2048 }

References vector3.

◆ AddLocalEulerAnglesY()

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

Definition at line 2050 of file ClassExtension.cs.

2051 {
2052 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
2053 transform.localEulerAngles = vector3;
2054 }

References vector3.

◆ AddLocalEulerAnglesZ()

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

Definition at line 2056 of file ClassExtension.cs.

2057 {
2058 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z + z);
2059 transform.localEulerAngles = vector3;
2060 }

References vector3.

◆ AddLocalPosition()

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

Definition at line 1894 of file ClassExtension.cs.

1895 {
1896 vector3.Set(transform.localPosition.x + x, transform.localPosition.y + y, transform.localPosition.z + z);
1897 transform.localPosition = vector3;
1898 }

References vector3.

◆ AddLocalPositionX()

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

Definition at line 1900 of file ClassExtension.cs.

1901 {
1902 vector3.Set(transform.localPosition.x + x, transform.localPosition.y, transform.localPosition.z);
1903 transform.localPosition = vector3;
1904 }

References vector3.

◆ AddLocalPositionY()

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

Definition at line 1906 of file ClassExtension.cs.

1907 {
1908 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1909 transform.localPosition = vector3;
1910 }

References vector3.

◆ AddLocalPositionZ()

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

Definition at line 1912 of file ClassExtension.cs.

1913 {
1914 vector3.Set(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + z);
1915 transform.localPosition = vector3;
1916 }

References vector3.

◆ AddLocalScale()

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

Definition at line 1942 of file ClassExtension.cs.

1943 {
1944 vector3.Set(transform.localScale.x + x, transform.localScale.y + y, transform.localScale.z + z);
1945 transform.localScale = vector3;
1946 }

References vector3.

◆ AddLocalScaleX()

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

Definition at line 1948 of file ClassExtension.cs.

1949 {
1950 vector3.Set(transform.localScale.x + x, transform.localScale.y, transform.localScale.z);
1951 transform.localScale = vector3;
1952 }

References vector3.

◆ AddLocalScaleY()

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

Definition at line 1954 of file ClassExtension.cs.

1955 {
1956 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1957 transform.localScale = vector3;
1958 }

References vector3.

◆ AddLocalScaleZ()

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

Definition at line 1960 of file ClassExtension.cs.

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

References vector3.

◆ AddPosition()

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

Definition at line 1846 of file ClassExtension.cs.

1847 {
1848 vector3.Set(transform.position.x + x, transform.position.y + y, transform.position.z + z);
1849 transform.position = vector3;
1850 }

References vector3.

◆ AddPositionX()

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

Definition at line 1852 of file ClassExtension.cs.

1853 {
1854 vector3.Set(transform.position.x + x, transform.position.y, transform.position.z);
1855 transform.position = vector3;
1856 }

References vector3.

◆ AddPositionY()

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

Definition at line 1858 of file ClassExtension.cs.

1859 {
1860 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1861 transform.position = vector3;
1862 }

References vector3.

◆ AddPositionZ()

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

Definition at line 1864 of file ClassExtension.cs.

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

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

2103 {
2104 if (angle < 0f)
2105 {
2106 return 360f - (0f - angle) % 360f;
2107 }
2108 return angle % 360f;
2109 }

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

1393 {
1394 r.pivot = t.pivot;
1395 r.sizeDelta = t.sizeDelta;
1396 r.anchorMin = t.anchorMin;
1397 r.anchorMax = t.anchorMax;
1398 r.anchoredPosition = t.anchoredPosition;
1399 }

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

1465 : Component
1466 {
1467 T result = null;
1468 for (int i = 0; i < c.transform.childCount; i++)
1469 {
1470 T component = c.transform.GetChild(i).GetComponent<T>();
1471 if ((bool)component && (name.IsEmpty() || name == component.name))
1472 {
1473 component.gameObject.SetActive(value: false);
1474 result = component;
1475 break;
1476 }
1477 }
1478 c.DestroyChildren();
1479 return result;
1480 }

◆ DestroyChildren()

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

Definition at line 1587 of file ClassExtension.cs.

1588 {
1589 if (!component || !component.transform)
1590 {
1591 Debug.LogWarning("DestroyChlidren:" + component);
1592 return;
1593 }
1594 for (int num = component.transform.childCount - 1; num >= 0; num--)
1595 {
1596 GameObject gameObject = component.transform.GetChild(num).gameObject;
1597 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1598 {
1599 UnityEngine.Object.DestroyImmediate(gameObject);
1600 }
1601 }
1602 }

References Debug.

◆ Distance()

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

Definition at line 1780 of file ClassExtension.cs.

1781 {
1782 return Vector3.Distance(t.position, pos);
1783 }

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

1483 {
1484 return c.Find<Transform>(name);
1485 }

◆ Find< T >()

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

Definition at line 1487 of file ClassExtension.cs.

1487 : Component
1488 {
1489 if (recursive)
1490 {
1491 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1492 foreach (T val in componentsInChildren)
1493 {
1494 if (name == null || name == val.name)
1495 {
1496 return val;
1497 }
1498 }
1499 return null;
1500 }
1501 for (int j = 0; j < c.transform.childCount; j++)
1502 {
1503 T component = c.transform.GetChild(j).GetComponent<T>();
1504 if ((bool)component && (name == null || name == component.name))
1505 {
1506 return component;
1507 }
1508 }
1509 return null;
1510 }

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

1513 {
1514 Transform transform = c.transform;
1515 for (int i = 0; i < transform.childCount; i++)
1516 {
1517 Transform child = transform.GetChild(i);
1518 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1519 {
1520 return child.gameObject;
1521 }
1522 }
1523 if ((bool)transform.parent)
1524 {
1525 return transform.parent.FindTagInParents(tag, includeInactive);
1526 }
1527 return null;
1528 }

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

2075 {
2076 for (int num = items.Count - 1; num >= 0; num--)
2077 {
2078 action(items[num]);
2079 }
2080 }

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

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

Definition at line 2082 of file ClassExtension.cs.

2083 {
2084 int num = items.Count - 1;
2085 while (num >= 0 && !action(items[num]))
2086 {
2087 num--;
2088 }
2089 }

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

1706 {
1707 Vector3 position = _rect.position;
1708 int width = Screen.width;
1709 int height = Screen.height;
1710 bool flag = position.y > (float)height * 0.5f;
1711 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1712 {
1713 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1714 {
1715 return RectPosition.Center;
1716 }
1717 if (!flag)
1718 {
1719 return RectPosition.BottomCenter;
1720 }
1721 return RectPosition.TopCenter;
1722 }
1723 if (position.x < (float)width * 0.5f)
1724 {
1725 if (!flag)
1726 {
1727 return RectPosition.BottomLEFT;
1728 }
1729 return RectPosition.TopLEFT;
1730 }
1731 if (!flag)
1732 {
1733 return RectPosition.BottomRIGHT;
1734 }
1735 return RectPosition.TopRIGHT;
1736 }

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

1530 : Component
1531 {
1532 for (int i = 0; i < c.childCount; i++)
1533 {
1534 T component = c.GetChild(i).GetComponent<T>();
1535 if ((bool)component)
1536 {
1537 return component;
1538 }
1539 }
1540 return null;
1541 }

◆ GetComponentInDirectChildren< T >()

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

Definition at line 1573 of file ClassExtension.cs.

1573 : Component
1574 {
1575 Transform transform = comp.transform;
1576 for (int i = 0; i < transform.childCount; i++)
1577 {
1578 T component = transform.GetChild(i).GetComponent<T>();
1579 if ((bool)component)
1580 {
1581 return component;
1582 }
1583 }
1584 return null;
1585 }

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

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

Definition at line 1558 of file ClassExtension.cs.

1558 : Component
1559 {
1560 List<T> list = new List<T>();
1561 Transform transform = comp.transform;
1562 for (int i = 0; i < transform.childCount; i++)
1563 {
1564 T component = transform.GetChild(i).GetComponent<T>();
1565 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1566 {
1567 list.Add(component);
1568 }
1569 }
1570 return list;
1571 }

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

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

Definition at line 1543 of file ClassExtension.cs.

1543 : Component
1544 {
1545 List<T> list = new List<T>();
1546 Transform transform = comp.transform;
1547 for (int i = 0; i < transform.childCount; i++)
1548 {
1549 T component = transform.GetChild(i).GetComponent<T>();
1550 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1551 {
1552 list.Add(component);
1553 }
1554 }
1555 return list;
1556 }

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

1758 {
1759 if (object.Equals(forward, Vector2.up))
1760 {
1761 return 90f;
1762 }
1763 object.Equals(forward, Vector2.right);
1764 return 0f;
1765 }

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

1739 {
1740 return trans.GetChild(trans.childCount - 1);
1741 }

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

1377 : Component
1378 {
1379 T val = t.gameObject.GetComponent<T>();
1380 if (!val)
1381 {
1382 val = t.gameObject.AddComponent<T>();
1383 }
1384 return val;
1385 }

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

2125 {
2126 Type typeFromHandle = typeof(UnityEventBase);
2127 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2128 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2129 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2130 Type type3 = typeof(List<>).MakeGenericType(type2);
2131 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2132 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2133 object value = field.GetValue(unityEvent);
2134 object value2 = field2.GetValue(value);
2135 return (int)type3.GetProperty("Count").GetValue(value2, null);
2136 }

◆ GetSelectable()

static Selectable ClassExtension.GetSelectable ( this GameObject  go)
inlinestatic

Definition at line 1423 of file ClassExtension.cs.

1424 {
1425 return go.GetComponentInChildren<Selectable>();
1426 }

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

2116 : ScriptableObject
2117 {
2118 string name = s.name;
2119 T val = UnityEngine.Object.Instantiate(s);
2120 val.name = name;
2121 return val;
2122 }

◆ IsChildOf()

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

Definition at line 1447 of file ClassExtension.cs.

1448 {
1449 if (c.transform == root.transform)
1450 {
1451 return true;
1452 }
1453 if ((bool)c.transform.parent)
1454 {
1455 return c.transform.parent.gameObject.IsChildOf(root);
1456 }
1457 return false;
1458 }

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

1438 {
1439 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1440 if ((bool)selectable)
1441 {
1442 return selectable.interactable;
1443 }
1444 return false;
1445 }

◆ IsMouseOver()

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

Definition at line 1604 of file ClassExtension.cs.

1605 {
1606 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1607 }

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

1461 {
1462 return c.gameObject.scene.name == null;
1463 }

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

1768 {
1769 self.LookAt2D(target.position, forward);
1770 }

References forward.

◆ LookAt2D() [2/2]

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

Definition at line 1772 of file ClassExtension.cs.

1773 {
1774 float forwardDiffPoint = GetForwardDiffPoint(forward);
1775 Vector3 vector = target - self.position;
1776 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1777 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1778 }
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 1203 of file ClassExtension.cs.

1204 {
1205 for (int i = 0; i < sels.Count; i++)
1206 {
1207 Selectable selectable = sels[i];
1208 Selectable selectable2 = sels[0];
1209 Navigation navigation = selectable.navigation;
1210 if (horizonal)
1211 {
1212 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1213 }
1214 if (asGroup)
1215 {
1216 for (int j = i + 1; j < sels.Count; j++)
1217 {
1218 if (sels[j].transform.position.y < selectable.transform.position.y)
1219 {
1220 selectable2 = sels[j];
1221 break;
1222 }
1223 }
1224 }
1225 else
1226 {
1227 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1228 }
1229 if (vertical)
1230 {
1231 navigation.selectOnDown = selectable2;
1232 }
1233 selectable.navigation = navigation;
1234 }
1235 for (int num = sels.Count - 1; num >= 0; num--)
1236 {
1237 Selectable selectable3 = sels[num];
1238 Selectable selectable4 = sels[sels.Count - 1];
1239 Navigation navigation2 = selectable3.navigation;
1240 if (horizonal)
1241 {
1242 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1243 }
1244 if (asGroup)
1245 {
1246 int num2 = sels.Count - 1;
1247 for (int num3 = num - 1; num3 >= 0; num3--)
1248 {
1249 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1250 {
1251 num2 = num3;
1252 break;
1253 }
1254 }
1255 int num4 = num2;
1256 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1257 {
1258 selectable4 = sels[num4];
1259 num4--;
1260 }
1261 }
1262 else
1263 {
1264 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1265 }
1266 if (vertical)
1267 {
1268 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1269 }
1270 navigation2.mode = Navigation.Mode.Explicit;
1271 selectable3.navigation = navigation2;
1272 }
1273 }

◆ LoopSelectable() [2/2]

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

Definition at line 1275 of file ClassExtension.cs.

1276 {
1277 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1278 for (int num = list.Count - 1; num >= 0; num--)
1279 {
1280 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1281 {
1282 list.RemoveAt(num);
1283 }
1284 }
1285 list.LoopSelectable(vertical, horizonal, asGroup);
1286 }

◆ LoopTail< T >()

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

Definition at line 1155 of file ClassExtension.cs.

1155 : Selectable
1156 {
1157 if (list.Count > 1)
1158 {
1159 Navigation navigation = list[0].navigation;
1160 Navigation navigation2 = list[list.Count - 1].navigation;
1161 if (vertical)
1162 {
1163 navigation.selectOnUp = list[list.Count - 1];
1164 navigation2.selectOnDown = list[0];
1165 }
1166 else
1167 {
1168 navigation.selectOnLeft = list[list.Count - 1];
1169 navigation2.selectOnRight = list[0];
1170 }
1171 list[0].navigation = navigation;
1172 list[list.Count - 1].navigation = navigation2;
1173 }
1174 }

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

1312 {
1313 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1314 }

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

1786 {
1787 v.x += v2.x;
1788 v.y += v2.y;
1789 return v;
1790 }

◆ PlusX()

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

Definition at line 1804 of file ClassExtension.cs.

1805 {
1806 v.x += a;
1807 return v;
1808 }

◆ PlusY()

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

Definition at line 1810 of file ClassExtension.cs.

1811 {
1812 v.y += a;
1813 return v;
1814 }

◆ PlusZ()

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

Definition at line 1816 of file ClassExtension.cs.

1817 {
1818 v.z += a;
1819 return v;
1820 }

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

2112 {
2113 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2114 }
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 1609 of file ClassExtension.cs.

1610 {
1611 if (recursive)
1612 {
1613 foreach (Transform item in c.transform)
1614 {
1615 if (item is RectTransform)
1616 {
1617 item.RebuildLayout(recursive: true);
1618 }
1619 }
1620 }
1621 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1622 }

References item.

◆ RebuildLayoutTo()

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

Definition at line 1633 of file ClassExtension.cs.

1634 {
1635 c.RebuildLayout();
1636 if (!(c == target) && (bool)c.transform.parent)
1637 {
1638 c.transform.parent.RebuildLayoutTo(target);
1639 }
1640 }

◆ RebuildLayoutTo< T >()

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

Definition at line 1624 of file ClassExtension.cs.

1624 : Component
1625 {
1626 c.RebuildLayout();
1627 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1628 {
1629 c.transform.parent.RebuildLayoutTo<T>();
1630 }
1631 }

◆ Rect()

static RectTransform ClassExtension.Rect ( this Component  c)
inlinestatic

Definition at line 1387 of file ClassExtension.cs.

1388 {
1389 return c.transform as RectTransform;
1390 }

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

2092 {
2093 int num = items.LastIndexOf(item);
2094 if (num < 0)
2095 {
2096 return false;
2097 }
2098 items.RemoveAt(num);
2099 return true;
2100 }

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

1407 {
1408 if (c.gameObject.activeSelf != enable)
1409 {
1410 c.gameObject.SetActive(enable);
1411 }
1412 }

Referenced by ContentQuest.RefreshTrackButtons().

◆ SetActive() [2/2]

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

Definition at line 1414 of file ClassExtension.cs.

1415 {
1416 if (c.gameObject.activeSelf != enable)
1417 {
1418 c.gameObject.SetActive(enable);
1419 onChangeState(enable);
1420 }
1421 }

◆ SetAlpha() [1/4]

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

Definition at line 1305 of file ClassExtension.cs.

1306 {
1307 c.a = a;
1308 return c;
1309 }

◆ SetAlpha() [2/4]

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

Definition at line 1295 of file ClassExtension.cs.

1296 {
1297 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1298 }

References Color.

◆ SetAlpha() [3/4]

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

Definition at line 1300 of file ClassExtension.cs.

1301 {
1302 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1303 }

References Color.

◆ SetAlpha() [4/4]

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

Definition at line 1344 of file ClassExtension.cs.

1345 {
1346 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1347 }

References Color.

◆ SetAnchor() [1/2]

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

Definition at line 1698 of file ClassExtension.cs.

1699 {
1700 Vector3 position = _rect.position;
1701 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1702 _rect.position = position;
1703 }

◆ SetAnchor() [2/2]

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

Definition at line 1658 of file ClassExtension.cs.

1659 {
1660 r.anchorMin = new Vector2(minX, minY);
1661 r.anchorMax = new Vector2(maxX, maxY);
1662 }

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

1967 {
1968 vector3.Set(x, y, z);
1969 transform.eulerAngles = vector3;
1970 }

References vector3.

◆ SetEulerAnglesX()

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

Definition at line 1972 of file ClassExtension.cs.

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

References vector3.

◆ SetEulerAnglesY()

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

Definition at line 1978 of file ClassExtension.cs.

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

References vector3.

◆ SetEulerAnglesZ()

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

Definition at line 1984 of file ClassExtension.cs.

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

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

1429 {
1430 obj.layer = layer;
1431 foreach (Transform item in obj.transform)
1432 {
1433 item.gameObject.SetLayerRecursively(layer);
1434 }
1435 }

References item.

◆ SetListener()

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

Definition at line 1335 of file ClassExtension.cs.

1336 {
1337 e.RemoveAllListeners();
1338 e.AddListener(delegate
1339 {
1340 action();
1341 });
1342 }

References Button.

◆ SetLocalEulerAngles()

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

Definition at line 2014 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalEulerAnglesX()

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

Definition at line 2020 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalEulerAnglesY()

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

Definition at line 2026 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalEulerAnglesZ()

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

Definition at line 2032 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPosition()

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

Definition at line 1870 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPositionX()

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

Definition at line 1876 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPositionY()

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

Definition at line 1882 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPositionZ()

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

Definition at line 1888 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScale()

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

Definition at line 1918 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleX()

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

Definition at line 1924 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleY()

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

Definition at line 1930 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleZ()

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

Definition at line 1936 of file ClassExtension.cs.

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

References vector3.

◆ SetNavigation()

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

Definition at line 1176 of file ClassExtension.cs.

1177 {
1178 if (!a || !b)
1179 {
1180 return;
1181 }
1182 Selectable component = a.GetComponent<Selectable>();
1183 Selectable component2 = b.GetComponent<Selectable>();
1184 if ((bool)component && (bool)component2)
1185 {
1186 Navigation navigation = component.navigation;
1187 Navigation navigation2 = component2.navigation;
1188 if (vertical)
1189 {
1190 navigation.selectOnUp = component2;
1191 navigation2.selectOnDown = component;
1192 }
1193 else
1194 {
1195 navigation.selectOnLeft = component2;
1196 navigation2.selectOnRight = component;
1197 }
1198 component.navigation = navigation;
1199 component2.navigation = navigation2;
1200 }
1201 }

◆ SetOnClick()

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

Definition at line 1326 of file ClassExtension.cs.

1327 {
1328 b.onClick.RemoveAllListeners();
1329 b.onClick.AddListener(delegate
1330 {
1331 action();
1332 });
1333 }

◆ SetPivot()

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

Definition at line 1653 of file ClassExtension.cs.

1654 {
1655 r.pivot = new Vector2(x, y);
1656 }

◆ SetPosition()

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

Definition at line 1822 of file ClassExtension.cs.

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

References vector3.

◆ SetPositionX()

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

Definition at line 1828 of file ClassExtension.cs.

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

References vector3.

◆ SetPositionY()

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

Definition at line 1834 of file ClassExtension.cs.

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

References vector3.

◆ SetPositionZ()

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

Definition at line 1840 of file ClassExtension.cs.

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

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

1643 {
1644 r.SetPivot(pivotX, pivotY);
1645 r.SetAnchor(minX, minY, maxX, maxY);
1646 if (w != -1f)
1647 {
1648 r.sizeDelta = new Vector2(w, h);
1649 }
1650 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1651 }

◆ SetScale()

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

Definition at line 1748 of file ClassExtension.cs.

1749 {
1750 float x = renderer.bounds.size.x;
1751 float y = renderer.bounds.size.y;
1752 float x2 = size / x;
1753 float y2 = size / y;
1754 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1755 }

◆ SetSlider() [1/2]

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

Definition at line 1349 of file ClassExtension.cs.

1350 {
1351 slider.SetSlider(value, action, -1, -1, notify);
1352 }

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

1355 {
1356 slider.onValueChanged.RemoveAllListeners();
1357 slider.onValueChanged.AddListener(delegate(float a)
1358 {
1359 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1360 });
1361 if (min != -1)
1362 {
1363 slider.minValue = min;
1364 slider.maxValue = max;
1365 }
1366 if (notify)
1367 {
1368 slider.value = value;
1369 }
1370 else
1371 {
1372 slider.SetValueWithoutNotify(value);
1373 }
1374 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1375 }

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

1799 {
1800 v.y = a;
1801 return v;
1802 }

◆ SetZ()

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

Definition at line 1792 of file ClassExtension.cs.

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

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

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

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

1289 {
1290 Color color = Color.white;
1291 ColorUtility.TryParseHtmlString("#" + s, out color);
1292 return color;
1293 }

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

1402 {
1403 c.SetActive(!c.gameObject.activeSelf);
1404 }

◆ ToggleKeyword()

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

Definition at line 2062 of file ClassExtension.cs.

2063 {
2064 if (enable)
2065 {
2066 m.EnableKeyword(id);
2067 }
2068 else
2069 {
2070 m.DisableKeyword(id);
2071 }
2072 }

◆ ToHex()

static string ClassExtension.ToHex ( this Color  c)
inlinestatic

Definition at line 1321 of file ClassExtension.cs.

1322 {
1323 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1324 }

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 }

◆ ToSentenceCase()

static string ClassExtension.ToSentenceCase ( this string  s)
inlinestatic

Definition at line 1132 of file ClassExtension.cs.

1133 {
1134 char[] array = s.ToCharArray();
1135 bool flag = true;
1136 for (int i = 0; i < array.Length; i++)
1137 {
1138 char c = array[i];
1139 if (char.IsLetter(c))
1140 {
1141 if (flag)
1142 {
1143 array[i] = char.ToUpperInvariant(c);
1144 }
1145 flag = false;
1146 }
1147 else if (c == '.' || c == '!' || c == '?')
1148 {
1149 flag = true;
1150 }
1151 }
1152 return new string(array);
1153 }

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

1744 {
1745 return new Vector2(self.x, self.z);
1746 }

◆ 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: