Elin Decompiled Documentation EA 23.320 Nyaightly Patch 1
Loading...
Searching...
No Matches
ClassExtension Class Reference

Static Public Member Functions

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

Static Public Attributes

static IPluralize pluralizer = new Pluralizer()
 

Static Private Member Functions

static float GetForwardDiffPoint (Vector2 forward)
 

Static Private Attributes

static Vector3 vector3
 

Detailed Description

Definition at line 14 of file ClassExtension.cs.

Member Function Documentation

◆ _SetAnchor()

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

Definition at line 1571 of file ClassExtension.cs.

1572 {
1573 switch (anchor)
1574 {
1575 case RectPosition.TopCenter:
1576 _rect.SetAnchor(0.5f, 1f, 0.5f, 1f);
1577 break;
1578 case RectPosition.BottomCenter:
1579 _rect.SetAnchor(0.5f, 0f, 0.5f, 0f);
1580 break;
1581 case RectPosition.TopLEFT:
1582 _rect.SetAnchor(0f, 1f, 0f, 1f);
1583 break;
1584 case RectPosition.TopRIGHT:
1585 _rect.SetAnchor(1f, 1f, 1f, 1f);
1586 break;
1587 case RectPosition.BottomLEFT:
1588 _rect.SetAnchor(0f, 0f, 0f, 0f);
1589 break;
1590 case RectPosition.BottomRIGHT:
1591 _rect.SetAnchor(1f, 0f, 1f, 0f);
1592 break;
1593 case RectPosition.Left:
1594 _rect.SetAnchor(0f, 0.5f, 0f, 0.5f);
1595 break;
1596 case RectPosition.Right:
1597 _rect.SetAnchor(1f, 0.5f, 1f, 0.5f);
1598 break;
1599 default:
1600 _rect.SetAnchor(0.5f, 0.5f, 0.5f, 0.5f);
1601 break;
1602 }
1603 }
RectPosition
Definition: RectPosition.cs:2

◆ AddArticle() [1/2]

static string ClassExtension.AddArticle ( this string  s)
inlinestatic

Definition at line 1004 of file ClassExtension.cs.

1005 {
1006 if (!Lang.setting.addArticle || s.Length < 1)
1007 {
1008 return s;
1009 }
1010 char c = s.ToLower()[0];
1011 s = ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a ") + s;
1012 return s;
1013 }
bool addArticle
Definition: LangSetting.cs:30
Definition: Lang.cs:7
static LangSetting setting
Definition: Lang.cs:55

References LangSetting.addArticle, and Lang.setting.

◆ AddArticle() [2/2]

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

Definition at line 1015 of file ClassExtension.cs.

1016 {
1017 if (!Lang.setting.addArticle || s.Length < 1)
1018 {
1019 return s;
1020 }
1021 char c = s[0];
1022 string text = ((num >= 2) ? (num.ToFormat() + " ") : ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "an " : "a "));
1023 if (num >= 2 && Lang.setting.pluralize)
1024 {
1025 s = ((replace.IsEmpty() || !s.Contains(replace) || s.Contains("limestone stone")) ? Pluralize(s) : s.Replace(replace, Pluralize(replace)));
1026 }
1027 return style switch
1028 {
1029 ArticleStyle.The => "_the".lang().ToTitleCase() + " " + ((num > 1) ? (num + " ") : "") + s,
1030 ArticleStyle.None => ((num > 1) ? (num.ToFormat() + " ") : "") + s.ToTitleCase(),
1031 _ => text + s,
1032 };
1033 }
ArticleStyle
Definition: ArticleStyle.cs:2
static string Pluralize(string s)
bool pluralize
Definition: LangSetting.cs:32

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

◆ AddEulerAngles()

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

Definition at line 1897 of file ClassExtension.cs.

1898 {
1899 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y + y, transform.eulerAngles.z + z);
1900 transform.eulerAngles = vector3;
1901 }
static Vector3 vector3

References vector3.

◆ AddEulerAnglesX()

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

Definition at line 1903 of file ClassExtension.cs.

1904 {
1905 vector3.Set(transform.eulerAngles.x + x, transform.eulerAngles.y, transform.eulerAngles.z);
1906 transform.eulerAngles = vector3;
1907 }

References vector3.

◆ AddEulerAnglesY()

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

Definition at line 1909 of file ClassExtension.cs.

1910 {
1911 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y + y, transform.eulerAngles.z);
1912 transform.eulerAngles = vector3;
1913 }

References vector3.

◆ AddEulerAnglesZ()

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

Definition at line 1915 of file ClassExtension.cs.

1916 {
1917 vector3.Set(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + z);
1918 transform.eulerAngles = vector3;
1919 }

References vector3.

◆ AddLocalEulerAngles()

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

Definition at line 1945 of file ClassExtension.cs.

1946 {
1947 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y + y, transform.localEulerAngles.z + z);
1948 transform.localEulerAngles = vector3;
1949 }

References vector3.

◆ AddLocalEulerAnglesX()

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

Definition at line 1951 of file ClassExtension.cs.

1952 {
1953 vector3.Set(transform.localEulerAngles.x + x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1954 transform.localEulerAngles = vector3;
1955 }

References vector3.

◆ AddLocalEulerAnglesY()

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

Definition at line 1957 of file ClassExtension.cs.

1958 {
1959 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y + y, transform.localEulerAngles.z);
1960 transform.localEulerAngles = vector3;
1961 }

References vector3.

◆ AddLocalEulerAnglesZ()

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

Definition at line 1963 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPosition()

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

Definition at line 1801 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPositionX()

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

Definition at line 1807 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalPositionY()

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

Definition at line 1813 of file ClassExtension.cs.

1814 {
1815 vector3.Set(transform.localPosition.x, transform.localPosition.y + y, transform.localPosition.z);
1816 transform.localPosition = vector3;
1817 }

References vector3.

◆ AddLocalPositionZ()

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

Definition at line 1819 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScale()

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

Definition at line 1849 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScaleX()

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

Definition at line 1855 of file ClassExtension.cs.

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

References vector3.

◆ AddLocalScaleY()

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

Definition at line 1861 of file ClassExtension.cs.

1862 {
1863 vector3.Set(transform.localScale.x, transform.localScale.y + y, transform.localScale.z);
1864 transform.localScale = vector3;
1865 }

References vector3.

◆ AddLocalScaleZ()

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

Definition at line 1867 of file ClassExtension.cs.

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

References vector3.

◆ AddPosition()

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

Definition at line 1753 of file ClassExtension.cs.

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

References vector3.

◆ AddPositionX()

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

Definition at line 1759 of file ClassExtension.cs.

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

References vector3.

◆ AddPositionY()

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

Definition at line 1765 of file ClassExtension.cs.

1766 {
1767 vector3.Set(transform.position.x, transform.position.y + y, transform.position.z);
1768 transform.position = vector3;
1769 }

References vector3.

◆ AddPositionZ()

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

Definition at line 1771 of file ClassExtension.cs.

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

References vector3.

◆ AddTag()

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

Definition at line 961 of file ClassExtension.cs.

962 {
963 if (!s.HasTag(id, splitter))
964 {
965 s = s + (s.IsEmpty() ? "" : ((object)splitter))?.ToString() + id;
966 }
967 return s;
968 }

◆ Bracket()

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

Definition at line 56 of file ClassExtension.cs.

57 {
58 return type switch
59 {
60 -1 => str,
61 1 => "「" + str + "」",
62 2 => "『" + str + "』",
63 3 => "《" + str + "》",
64 4 => "(" + str + ")",
65 _ => "_bracketLeft".lang() + str + "_bracketRight".lang(),
66 };
67 }

◆ Calc()

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

Definition at line 671 of file ClassExtension.cs.

672 {
673 return Cal.Calcuate(str.Replace("p2", p2.ToString() ?? "").Replace("p", power.ToString() ?? "").Replace("e", ele.ToString() ?? "")
674 .Replace(";", ","));
675 }

◆ Clamp()

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

Definition at line 183 of file ClassExtension.cs.

184 {
185 if (v < min)
186 {
187 v = ((!loop) ? min : max);
188 }
189 else if (v > max)
190 {
191 v = ((!loop) ? max : min);
192 }
193 return v;
194 }

◆ Clamp< TValue >()

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

Definition at line 584 of file ClassExtension.cs.

585 {
586 if (i < 0)
587 {
588 i = 0;
589 }
590 else if (i >= source.Count)
591 {
592 i = source.Count - 1;
593 }
594 return source[i];
595 }

◆ ClampAngle()

static float ClassExtension.ClampAngle ( this float  angle)
inlinestatic

Definition at line 1998 of file ClassExtension.cs.

1999 {
2000 if (angle < 0f)
2001 {
2002 return 360f - (0f - angle) % 360f;
2003 }
2004 return angle % 360f;
2005 }

◆ ClampMax()

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

Definition at line 205 of file ClassExtension.cs.

206 {
207 if (v <= max)
208 {
209 return v;
210 }
211 return max;
212 }

◆ ClampMin()

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

Definition at line 196 of file ClassExtension.cs.

197 {
198 if (v >= min)
199 {
200 return v;
201 }
202 return min;
203 }

◆ Contains()

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

Definition at line 834 of file ClassExtension.cs.

835 {
836 if (strs == null || strs.Length == 0)
837 {
838 return false;
839 }
840 for (int i = 0; i < strs.Length; i++)
841 {
842 if (strs[i] == id)
843 {
844 return true;
845 }
846 }
847 return false;
848 }

◆ Copy< TValue >()

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

Definition at line 336 of file ClassExtension.cs.

337 {
338 return list.ToList();
339 }

◆ CopyKeys< TKey, TValue >()

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

Definition at line 394 of file ClassExtension.cs.

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

◆ CopyRect()

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

Definition at line 1299 of file ClassExtension.cs.

1300 {
1301 r.pivot = t.pivot;
1302 r.sizeDelta = t.sizeDelta;
1303 r.anchorMin = t.anchorMin;
1304 r.anchorMax = t.anchorMax;
1305 r.anchoredPosition = t.anchoredPosition;
1306 }

◆ CopyValues< TKey, TValue >()

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

Definition at line 401 of file ClassExtension.cs.

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

◆ CreateMold< T >()

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

Definition at line 1372 of file ClassExtension.cs.

1372 : Component
1373 {
1374 T result = null;
1375 for (int i = 0; i < c.transform.childCount; i++)
1376 {
1377 T component = c.transform.GetChild(i).GetComponent<T>();
1378 if ((bool)component && (name.IsEmpty() || name == component.name))
1379 {
1380 component.gameObject.SetActive(value: false);
1381 result = component;
1382 break;
1383 }
1384 }
1385 c.DestroyChildren();
1386 return result;
1387 }

◆ DestroyChildren()

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

Definition at line 1494 of file ClassExtension.cs.

1495 {
1496 if (!component || !component.transform)
1497 {
1498 Debug.LogWarning("DestroyChlidren:" + component);
1499 return;
1500 }
1501 for (int num = component.transform.childCount - 1; num >= 0; num--)
1502 {
1503 GameObject gameObject = component.transform.GetChild(num).gameObject;
1504 if ((!ignoreDestroy || !(gameObject.tag == "IgnoreDestroy")) && (destroyInactive || gameObject.activeSelf))
1505 {
1506 UnityEngine.Object.DestroyImmediate(gameObject);
1507 }
1508 }
1509 }

References Debug.

◆ Distance()

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

Definition at line 1687 of file ClassExtension.cs.

1688 {
1689 return Vector3.Distance(t.position, pos);
1690 }

◆ Each< TValue >()

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

Definition at line 341 of file ClassExtension.cs.

342 {
343 for (int num = list.Count - 1; num >= 0; num--)
344 {
345 action(list[num]);
346 }
347 }

◆ Evalute()

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

Definition at line 850 of file ClassExtension.cs.

851 {
852 return array[(int)Mathf.Clamp((float)(array.Length - 1) * val, 0f, array.Length - 1)];
853 }

◆ Find()

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

Definition at line 1389 of file ClassExtension.cs.

1390 {
1391 return c.Find<Transform>(name);
1392 }

◆ Find< T >()

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

Definition at line 1394 of file ClassExtension.cs.

1394 : Component
1395 {
1396 if (recursive)
1397 {
1398 T[] componentsInChildren = c.transform.GetComponentsInChildren<T>();
1399 foreach (T val in componentsInChildren)
1400 {
1401 if (name == null || name == val.name)
1402 {
1403 return val;
1404 }
1405 }
1406 return null;
1407 }
1408 for (int j = 0; j < c.transform.childCount; j++)
1409 {
1410 T component = c.transform.GetChild(j).GetComponent<T>();
1411 if ((bool)component && (name == null || name == component.name))
1412 {
1413 return component;
1414 }
1415 }
1416 return null;
1417 }

◆ FindMax< T >()

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

Definition at line 619 of file ClassExtension.cs.

620 {
621 int num = int.MinValue;
622 T result = default(T);
623 foreach (T item in list)
624 {
625 int num2 = func(item);
626 if (num2 > num)
627 {
628 num = num2;
629 result = item;
630 }
631 }
632 return result;
633 }

References item.

◆ FindTagInParents()

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

Definition at line 1419 of file ClassExtension.cs.

1420 {
1421 Transform transform = c.transform;
1422 for (int i = 0; i < transform.childCount; i++)
1423 {
1424 Transform child = transform.GetChild(i);
1425 if ((includeInactive || child.gameObject.activeSelf) && child.tag == tag)
1426 {
1427 return child.gameObject;
1428 }
1429 }
1430 if ((bool)transform.parent)
1431 {
1432 return transform.parent.FindTagInParents(tag, includeInactive);
1433 }
1434 return null;
1435 }

◆ FirstItem< TKey, TValue >()

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

Definition at line 510 of file ClassExtension.cs.

511 {
512 if (source == null)
513 {
514 return default(TValue);
515 }
516 return source[source.First().Key];
517 }

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

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

Definition at line 1981 of file ClassExtension.cs.

1982 {
1983 for (int num = items.Count - 1; num >= 0; num--)
1984 {
1985 action(items[num]);
1986 }
1987 }

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

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

Definition at line 1989 of file ClassExtension.cs.

1990 {
1991 int num = items.Count - 1;
1992 while (num >= 0 && !action(items[num]))
1993 {
1994 num--;
1995 }
1996 }

◆ FromInt2()

static float ClassExtension.FromInt2 ( this int  a)
inlinestatic

Definition at line 105 of file ClassExtension.cs.

106 {
107 return (float)a / 100f;
108 }

◆ FromInt3()

static float ClassExtension.FromInt3 ( this int  a)
inlinestatic

Definition at line 95 of file ClassExtension.cs.

96 {
97 return (float)a / 1000f;
98 }

◆ GetAnchor()

static RectPosition ClassExtension.GetAnchor ( this RectTransform  _rect)
inlinestatic

Definition at line 1612 of file ClassExtension.cs.

1613 {
1614 Vector3 position = _rect.position;
1615 int width = Screen.width;
1616 int height = Screen.height;
1617 bool flag = position.y > (float)height * 0.5f;
1618 if (position.x > (float)width * 0.3f && position.x < (float)width * 0.7f)
1619 {
1620 if (position.y > (float)height * 0.3f && position.y < (float)height * 0.7f)
1621 {
1622 return RectPosition.Center;
1623 }
1624 if (!flag)
1625 {
1626 return RectPosition.BottomCenter;
1627 }
1628 return RectPosition.TopCenter;
1629 }
1630 if (position.x < (float)width * 0.5f)
1631 {
1632 if (!flag)
1633 {
1634 return RectPosition.BottomLEFT;
1635 }
1636 return RectPosition.TopLEFT;
1637 }
1638 if (!flag)
1639 {
1640 return RectPosition.BottomRIGHT;
1641 }
1642 return RectPosition.TopRIGHT;
1643 }

◆ GetBit()

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

Definition at line 76 of file ClassExtension.cs.

77 {
78 return (pByte & (1 << bitNo)) != 0;
79 }

◆ GetComponentInChildrenExcludSelf< T >()

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

Definition at line 1437 of file ClassExtension.cs.

1437 : Component
1438 {
1439 for (int i = 0; i < c.childCount; i++)
1440 {
1441 T component = c.GetChild(i).GetComponent<T>();
1442 if ((bool)component)
1443 {
1444 return component;
1445 }
1446 }
1447 return null;
1448 }

◆ GetComponentInDirectChildren< T >()

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

Definition at line 1480 of file ClassExtension.cs.

1480 : Component
1481 {
1482 Transform transform = comp.transform;
1483 for (int i = 0; i < transform.childCount; i++)
1484 {
1485 T component = transform.GetChild(i).GetComponent<T>();
1486 if ((bool)component)
1487 {
1488 return component;
1489 }
1490 }
1491 return null;
1492 }

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

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

Definition at line 1465 of file ClassExtension.cs.

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

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

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

Definition at line 1450 of file ClassExtension.cs.

1450 : Component
1451 {
1452 List<T> list = new List<T>();
1453 Transform transform = comp.transform;
1454 for (int i = 0; i < transform.childCount; i++)
1455 {
1456 T component = transform.GetChild(i).GetComponent<T>();
1457 if ((bool)component && (includeInactive || component.gameObject.activeInHierarchy))
1458 {
1459 list.Add(component);
1460 }
1461 }
1462 return list;
1463 }

◆ GetField< T >()

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

Definition at line 229 of file ClassExtension.cs.

230 {
231 return (T)o.GetType().GetField(name).GetValue(o);
232 }

◆ GetForwardDiffPoint()

static float ClassExtension.GetForwardDiffPoint ( Vector2  forward)
inlinestaticprivate

Definition at line 1664 of file ClassExtension.cs.

1665 {
1666 if (object.Equals(forward, Vector2.up))
1667 {
1668 return 90f;
1669 }
1670 object.Equals(forward, Vector2.right);
1671 return 0f;
1672 }

References forward.

Referenced by LookAt2D().

◆ GetFullFileNameWithoutExtension() [1/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this FileInfo  fileInfo)
inlinestatic

Definition at line 985 of file ClassExtension.cs.

986 {
987 return fileInfo.Directory.FullName + "/" + Path.GetFileNameWithoutExtension(fileInfo.Name);
988 }

◆ GetFullFileNameWithoutExtension() [2/2]

static string ClassExtension.GetFullFileNameWithoutExtension ( this string  path)
inlinestatic

Definition at line 990 of file ClassExtension.cs.

991 {
992 return new FileInfo(path).GetFullFileNameWithoutExtension();
993 }

◆ GetLastChild()

static Transform ClassExtension.GetLastChild ( this Transform  trans)
inlinestatic

Definition at line 1645 of file ClassExtension.cs.

1646 {
1647 return trans.GetChild(trans.childCount - 1);
1648 }

◆ GetList< T >()

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

Definition at line 597 of file ClassExtension.cs.

598 {
599 List<T> list = new List<T>();
600 foreach (object value in source.Values)
601 {
602 if (value is T)
603 {
604 list.Add((T)value);
605 }
606 }
607 return list;
608 }

◆ GetOrCreate< T >()

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

Definition at line 1284 of file ClassExtension.cs.

1284 : Component
1285 {
1286 T val = t.gameObject.GetComponent<T>();
1287 if (!val)
1288 {
1289 val = t.gameObject.AddComponent<T>();
1290 }
1291 return val;
1292 }

◆ GetOrCreate< TKey, TValue >()

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

Definition at line 383 of file ClassExtension.cs.

384 {
385 TValue val = dict.TryGetValue(key);
386 if (val == null)
387 {
388 val = ((func != null) ? func() : Activator.CreateInstance<TValue>());
389 dict.Add(key, val);
390 }
391 return val;
392 }

◆ GetProperty< T >()

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

Definition at line 239 of file ClassExtension.cs.

240 {
241 return (T)o.GetType().GetProperty(name).GetValue(o);
242 }

◆ GetRuntimeEventCount()

static int ClassExtension.GetRuntimeEventCount ( this UnityEventBase  unityEvent)
inlinestatic

Definition at line 2020 of file ClassExtension.cs.

2021 {
2022 Type typeFromHandle = typeof(UnityEventBase);
2023 Assembly assembly = Assembly.GetAssembly(typeFromHandle);
2024 Type type = assembly.GetType("UnityEngine.Events.InvokableCallList");
2025 Type type2 = assembly.GetType("UnityEngine.Events.BaseInvokableCall");
2026 Type type3 = typeof(List<>).MakeGenericType(type2);
2027 FieldInfo field = typeFromHandle.GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic);
2028 FieldInfo field2 = type.GetField("m_RuntimeCalls", BindingFlags.Instance | BindingFlags.NonPublic);
2029 object value = field.GetValue(unityEvent);
2030 object value2 = field2.GetValue(value);
2031 return (int)type3.GetProperty("Count").GetValue(value2, null);
2032 }

◆ GetSelectable()

static Selectable ClassExtension.GetSelectable ( this GameObject  go)
inlinestatic

Definition at line 1330 of file ClassExtension.cs.

1331 {
1332 return go.GetComponentInChildren<Selectable>();
1333 }

◆ HasField< T >()

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

Definition at line 219 of file ClassExtension.cs.

220 {
221 FieldInfo field = o.GetType().GetField(name);
222 if (field != null)
223 {
224 return typeof(T).IsAssignableFrom(field.FieldType);
225 }
226 return false;
227 }

◆ HasTag()

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

Definition at line 950 of file ClassExtension.cs.

951 {
952 return s.Split(splitter).Contains(id);
953 }

◆ IndexOf()

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

Definition at line 303 of file ClassExtension.cs.

304 {
305 if (!go)
306 {
307 return -1;
308 }
309 for (int i = 0; i < list.Count; i++)
310 {
311 if (list[i].gameObject == go)
312 {
313 return i;
314 }
315 }
316 return -1;
317 }

◆ Instantiate< T >()

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

Definition at line 2012 of file ClassExtension.cs.

2012 : ScriptableObject
2013 {
2014 string name = s.name;
2015 T val = UnityEngine.Object.Instantiate(s);
2016 val.name = name;
2017 return val;
2018 }

◆ IsChildOf()

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

Definition at line 1354 of file ClassExtension.cs.

1355 {
1356 if (c.transform == root.transform)
1357 {
1358 return true;
1359 }
1360 if ((bool)c.transform.parent)
1361 {
1362 return c.transform.parent.gameObject.IsChildOf(root);
1363 }
1364 return false;
1365 }

◆ IsEmpty() [1/3]

static bool ClassExtension.IsEmpty ( this Array  array)
inlinestatic

Definition at line 294 of file ClassExtension.cs.

295 {
296 if (array != null)
297 {
298 return array.Length == 0;
299 }
300 return true;
301 }

◆ IsEmpty() [2/3]

static bool ClassExtension.IsEmpty ( this string  str)
inlinestatic

Definition at line 791 of file ClassExtension.cs.

792 {
793 if (str != null)
794 {
795 return str == "";
796 }
797 return true;
798 }

◆ IsEmpty() [3/3]

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

Definition at line 800 of file ClassExtension.cs.

801 {
802 if (str != null && !(str == ""))
803 {
804 return str;
805 }
806 return defaultStr;
807 }

◆ IsInteractable()

static bool ClassExtension.IsInteractable ( this GameObject  obj)
inlinestatic

Definition at line 1344 of file ClassExtension.cs.

1345 {
1346 Selectable selectable = (obj ? obj.GetComponent<Selectable>() : null);
1347 if ((bool)selectable)
1348 {
1349 return selectable.interactable;
1350 }
1351 return false;
1352 }

◆ IsMouseOver()

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

Definition at line 1511 of file ClassExtension.cs.

1512 {
1513 return RectTransformUtility.RectangleContainsScreenPoint(r, Input.mousePosition, cam);
1514 }

◆ IsNull()

static bool ClassExtension.IsNull ( this object  o)
inlinestatic

Definition at line 123 of file ClassExtension.cs.

124 {
125 return o == null;
126 }

◆ IsOn()

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

Definition at line 128 of file ClassExtension.cs.

129 {
130 BitArray32 bitArray = default(BitArray32);
131 bitArray.SetInt(data);
132 return bitArray[digit];
133 }
void SetInt(int i)
Definition: BitArray32.cs:89

References BitArray32.SetInt().

◆ IsPrefab()

static bool ClassExtension.IsPrefab ( this Component  c)
inlinestatic

Definition at line 1367 of file ClassExtension.cs.

1368 {
1369 return c.gameObject.scene.name == null;
1370 }

◆ lang() [1/2]

static string ClassExtension.lang ( this string  s)
inlinestatic

Definition at line 20 of file ClassExtension.cs.

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

References Lang.Get().

◆ lang() [2/2]

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

Definition at line 31 of file ClassExtension.cs.

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

References Lang.Parse().

◆ langGame() [1/2]

static string ClassExtension.langGame ( this string  s)
inlinestatic

Definition at line 41 of file ClassExtension.cs.

42 {
43 return Lang.Game.Get(s);
44 }
static LangGame Game
Definition: Lang.cs:49
string Get(string id)
Definition: SourceLang.cs:12

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

◆ langGame() [2/2]

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

Definition at line 46 of file ClassExtension.cs.

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

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

◆ langList()

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

Definition at line 36 of file ClassExtension.cs.

37 {
38 return Lang.GetList(s);
39 }
static string[] GetList(string id)
Definition: Lang.cs:113

References Lang.GetList().

◆ langPlural()

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

Definition at line 25 of file ClassExtension.cs.

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

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

◆ LastItem< TValue >()

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

Definition at line 519 of file ClassExtension.cs.

520 {
521 if (source.Count != 0)
522 {
523 return source[source.Count - 1];
524 }
525 return default(TValue);
526 }

◆ LookAt2D() [1/2]

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

Definition at line 1674 of file ClassExtension.cs.

1675 {
1676 self.LookAt2D(target.position, forward);
1677 }

References forward.

◆ LookAt2D() [2/2]

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

Definition at line 1679 of file ClassExtension.cs.

1680 {
1681 float forwardDiffPoint = GetForwardDiffPoint(forward);
1682 Vector3 vector = target - self.position;
1683 float num = Mathf.Atan2(vector.y, vector.x) * 57.29578f;
1684 self.rotation = Quaternion.AngleAxis(num - forwardDiffPoint, Vector3.forward);
1685 }
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 1110 of file ClassExtension.cs.

1111 {
1112 for (int i = 0; i < sels.Count; i++)
1113 {
1114 Selectable selectable = sels[i];
1115 Selectable selectable2 = sels[0];
1116 Navigation navigation = selectable.navigation;
1117 if (horizonal)
1118 {
1119 navigation.selectOnRight = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1120 }
1121 if (asGroup)
1122 {
1123 for (int j = i + 1; j < sels.Count; j++)
1124 {
1125 if (sels[j].transform.position.y < selectable.transform.position.y)
1126 {
1127 selectable2 = sels[j];
1128 break;
1129 }
1130 }
1131 }
1132 else
1133 {
1134 selectable2 = ((i + 1 < sels.Count) ? sels[i + 1] : selectable2);
1135 }
1136 if (vertical)
1137 {
1138 navigation.selectOnDown = selectable2;
1139 }
1140 selectable.navigation = navigation;
1141 }
1142 for (int num = sels.Count - 1; num >= 0; num--)
1143 {
1144 Selectable selectable3 = sels[num];
1145 Selectable selectable4 = sels[sels.Count - 1];
1146 Navigation navigation2 = selectable3.navigation;
1147 if (horizonal)
1148 {
1149 navigation2.selectOnLeft = ((num > 0) ? sels[num - 1] : selectable4);
1150 }
1151 if (asGroup)
1152 {
1153 int num2 = sels.Count - 1;
1154 for (int num3 = num - 1; num3 >= 0; num3--)
1155 {
1156 if (sels[num3].transform.position.y > selectable3.transform.position.y)
1157 {
1158 num2 = num3;
1159 break;
1160 }
1161 }
1162 int num4 = num2;
1163 while (num4 >= 0 && !(sels[num4].transform.position.y > sels[num2].transform.position.y))
1164 {
1165 selectable4 = sels[num4];
1166 num4--;
1167 }
1168 }
1169 else
1170 {
1171 selectable4 = ((num > 0) ? sels[num - 1] : selectable4);
1172 }
1173 if (vertical)
1174 {
1175 navigation2.selectOnUp = ((selectable4 == selectable3) ? sels[sels.Count - 1] : selectable4);
1176 }
1177 navigation2.mode = Navigation.Mode.Explicit;
1178 selectable3.navigation = navigation2;
1179 }
1180 }

◆ LoopSelectable() [2/2]

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

Definition at line 1182 of file ClassExtension.cs.

1183 {
1184 List<Selectable> list = l.GetComponentsInChildren<Selectable>().ToList();
1185 for (int num = list.Count - 1; num >= 0; num--)
1186 {
1187 if (!list[num].interactable || list[num].navigation.mode == Navigation.Mode.None)
1188 {
1189 list.RemoveAt(num);
1190 }
1191 }
1192 list.LoopSelectable(vertical, horizonal, asGroup);
1193 }

◆ LoopTail< T >()

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

Definition at line 1062 of file ClassExtension.cs.

1062 : Selectable
1063 {
1064 if (list.Count > 1)
1065 {
1066 Navigation navigation = list[0].navigation;
1067 Navigation navigation2 = list[list.Count - 1].navigation;
1068 if (vertical)
1069 {
1070 navigation.selectOnUp = list[list.Count - 1];
1071 navigation2.selectOnDown = list[0];
1072 }
1073 else
1074 {
1075 navigation.selectOnLeft = list[list.Count - 1];
1076 navigation2.selectOnRight = list[0];
1077 }
1078 list[0].navigation = navigation;
1079 list[list.Count - 1].navigation = navigation2;
1080 }
1081 }

◆ Minimum()

static int ClassExtension.Minimum ( this int  i)
inlinestatic

Definition at line 110 of file ClassExtension.cs.

111 {
112 if (i != 0)
113 {
114 if (i <= 0)
115 {
116 return -1;
117 }
118 return 1;
119 }
120 return 0;
121 }

◆ Move< TValue >()

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

Definition at line 319 of file ClassExtension.cs.

320 {
321 int num = list.IndexOf(target);
322 int num2 = num + a;
323 if (num2 < 0)
324 {
325 num2 = list.Count - 1;
326 }
327 if (num2 >= list.Count)
328 {
329 num2 = 0;
330 }
331 list.Remove(target);
332 list.Insert(num2, target);
333 return list[num];
334 }

◆ Multiply()

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

Definition at line 1218 of file ClassExtension.cs.

1219 {
1220 return new Color(c.r * mtp + add, c.g * mtp + add, c.b * mtp + add, c.a);
1221 }

References Color.

◆ NextEnum< T >()

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

Definition at line 155 of file ClassExtension.cs.

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

◆ NextIndex< TValue >()

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

Definition at line 542 of file ClassExtension.cs.

543 {
544 if (val == null)
545 {
546 return 0;
547 }
548 int num = source.IndexOf(val) + 1;
549 if (num >= source.Count)
550 {
551 num = 0;
552 }
553 return num;
554 }

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

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

Definition at line 528 of file ClassExtension.cs.

529 {
530 index++;
531 if (index >= source.Count)
532 {
533 index = 0;
534 }
535 if (source.Count != 0)
536 {
537 return source[index];
538 }
539 return default(TValue);
540 }

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

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

Definition at line 556 of file ClassExtension.cs.

557 {
558 int num = source.IndexOf(val) + 1;
559 if (num >= source.Count)
560 {
561 num = 0;
562 }
563 if (source.Count != 0)
564 {
565 return source[num];
566 }
567 return default(TValue);
568 }

◆ Parentheses()

static string ClassExtension.Parentheses ( this string  str)
inlinestatic

Definition at line 51 of file ClassExtension.cs.

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

◆ Pluralize()

static string ClassExtension.Pluralize ( string  s)
inlinestatic

Definition at line 995 of file ClassExtension.cs.

996 {
997 if (s == "talisman")
998 {
999 return "talismans";
1000 }
1001 return pluralizer.Pluralize(s);
1002 }

References pluralizer.

Referenced by AddArticle().

◆ Plus()

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

Definition at line 1692 of file ClassExtension.cs.

1693 {
1694 v.x += v2.x;
1695 v.y += v2.y;
1696 return v;
1697 }

◆ PlusX()

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

Definition at line 1711 of file ClassExtension.cs.

1712 {
1713 v.x += a;
1714 return v;
1715 }

◆ PlusY()

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

Definition at line 1717 of file ClassExtension.cs.

1718 {
1719 v.y += a;
1720 return v;
1721 }

◆ PlusZ()

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

Definition at line 1723 of file ClassExtension.cs.

1724 {
1725 v.z += a;
1726 return v;
1727 }

◆ PrevEnum< T >()

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

Definition at line 160 of file ClassExtension.cs.

160 : struct
161 {
162 return ((T[])Enum.GetValues(src.GetType())).PrevItem(src);
163 }

◆ PrevItem< TValue >()

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

Definition at line 570 of file ClassExtension.cs.

571 {
572 int num = source.IndexOf(val) - 1;
573 if (num < 0)
574 {
575 num = source.Count - 1;
576 }
577 if (source.Count != 0)
578 {
579 return source[num];
580 }
581 return default(TValue);
582 }

◆ Random()

static Vector3 ClassExtension.Random ( this Vector3  v)
inlinestatic

Definition at line 2007 of file ClassExtension.cs.

2008 {
2009 return new Vector3(Rand.Range(0f - v.x, v.x), Rand.Range(0f - v.y, v.y), Rand.Range(0f - v.z, v.z));
2010 }
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 408 of file ClassExtension.cs.

409 {
410 int num = ie.Count();
411 if (num == 0)
412 {
413 return default(T);
414 }
415 return ie.ElementAt(Rand.rnd(num));
416 }
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 418 of file ClassExtension.cs.

419 {
420 if (source.Count != 0)
421 {
422 return source.ElementAt(Rand.rnd(source.Count)).Value;
423 }
424 return default(TValue);
425 }

References Rand.rnd().

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

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

Definition at line 427 of file ClassExtension.cs.

428 {
429 if (source.Count != 0)
430 {
431 return source[Rand.rnd(source.Count)];
432 }
433 return default(TValue);
434 }

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

461 {
462 for (int i = 0; i < 100; i++)
463 {
464 TValue val = source[Rand.rnd(source.Count)];
465 if (funcValid(val))
466 {
467 return val;
468 }
469 }
470 return defaultValue;
471 }

References Rand.rnd().

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

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

Definition at line 441 of file ClassExtension.cs.

442 {
443 if (source.Count > 1)
444 {
445 int num;
446 do
447 {
448 num = Rand.rnd(source.Count);
449 }
450 while (num == exclude);
451 return source[num];
452 }
453 if (source.Count == 1)
454 {
455 return source[0];
456 }
457 return default(TValue);
458 }

References Rand.rnd().

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

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

Definition at line 436 of file ClassExtension.cs.

437 {
438 return source.RandomItem(source.IndexOf(exclude));
439 }

◆ RandomItemWeighted< TValue >()

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

Definition at line 473 of file ClassExtension.cs.

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

References item, and Rand.Range().

◆ RebuildLayout()

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

Definition at line 1516 of file ClassExtension.cs.

1517 {
1518 if (recursive)
1519 {
1520 foreach (Transform item in c.transform)
1521 {
1522 if (item is RectTransform)
1523 {
1524 item.RebuildLayout(recursive: true);
1525 }
1526 }
1527 }
1528 LayoutRebuilder.ForceRebuildLayoutImmediate(c.transform as RectTransform);
1529 }

References item.

◆ RebuildLayoutTo()

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

Definition at line 1540 of file ClassExtension.cs.

1541 {
1542 c.RebuildLayout();
1543 if (!(c == target) && (bool)c.transform.parent)
1544 {
1545 c.transform.parent.RebuildLayoutTo(target);
1546 }
1547 }

◆ RebuildLayoutTo< T >()

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

Definition at line 1531 of file ClassExtension.cs.

1531 : Component
1532 {
1533 c.RebuildLayout();
1534 if ((bool)c.transform.parent && !c.transform.parent.GetComponent<T>())
1535 {
1536 c.transform.parent.RebuildLayoutTo<T>();
1537 }
1538 }

◆ Rect()

static RectTransform ClassExtension.Rect ( this Component  c)
inlinestatic

Definition at line 1294 of file ClassExtension.cs.

1295 {
1296 return c.transform as RectTransform;
1297 }

◆ Remainder< TValue >()

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

Definition at line 501 of file ClassExtension.cs.

502 {
503 if (source.Count != 0)
504 {
505 return source[divider % source.Count];
506 }
507 return default(TValue);
508 }

◆ RemoveAllTags()

static string ClassExtension.RemoveAllTags ( this string  text)
inlinestatic

Definition at line 662 of file ClassExtension.cs.

663 {
664 if (string.IsNullOrEmpty(text))
665 {
666 return text;
667 }
668 return Regex.Replace(text, "<.*?>", "");
669 }

◆ RemoveNewline()

static string ClassExtension.RemoveNewline ( this string  text)
inlinestatic

Definition at line 653 of file ClassExtension.cs.

654 {
655 if (string.IsNullOrEmpty(text))
656 {
657 return text;
658 }
659 return text.Replace("\r", "").Replace("\n", "");
660 }

◆ RemoveTag()

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

Definition at line 970 of file ClassExtension.cs.

971 {
972 string[] array = s.Split(splitter);
973 s = "";
974 string[] array2 = array;
975 foreach (string text in array2)
976 {
977 if (!(text == id))
978 {
979 s.AddTag(text, splitter);
980 }
981 }
982 return s;
983 }

◆ Repeat()

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

Definition at line 766 of file ClassExtension.cs.

767 {
768 StringBuilder stringBuilder = new StringBuilder();
769 for (int i = 0; i < Mathf.Abs(count); i++)
770 {
771 stringBuilder.Append(str);
772 }
773 return stringBuilder.ToString();
774 }

◆ Set< T1, T2 >()

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

Definition at line 635 of file ClassExtension.cs.

636 {
637 dic.Clear();
638 foreach (KeyValuePair<T1, T2> item in from)
639 {
640 dic[item.Key] = item.Value;
641 }
642 }

References item.

◆ SetActive() [1/2]

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

Definition at line 1313 of file ClassExtension.cs.

1314 {
1315 if (c.gameObject.activeSelf != enable)
1316 {
1317 c.gameObject.SetActive(enable);
1318 }
1319 }

Referenced by ContentQuest.RefreshTrackButtons().

◆ SetActive() [2/2]

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

Definition at line 1321 of file ClassExtension.cs.

1322 {
1323 if (c.gameObject.activeSelf != enable)
1324 {
1325 c.gameObject.SetActive(enable);
1326 onChangeState(enable);
1327 }
1328 }

◆ SetAlpha() [1/4]

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

Definition at line 1212 of file ClassExtension.cs.

1213 {
1214 c.a = a;
1215 return c;
1216 }

◆ SetAlpha() [2/4]

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

Definition at line 1202 of file ClassExtension.cs.

1203 {
1204 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1205 }

References Color.

◆ SetAlpha() [3/4]

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

Definition at line 1207 of file ClassExtension.cs.

1208 {
1209 c.color = new Color(c.color.r, c.color.g, c.color.b, a);
1210 }

References Color.

◆ SetAlpha() [4/4]

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

Definition at line 1251 of file ClassExtension.cs.

1252 {
1253 text.color = new Color(text.color.r, text.color.g, text.color.b, aloha);
1254 }

References Color.

◆ SetAnchor() [1/2]

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

Definition at line 1605 of file ClassExtension.cs.

1606 {
1607 Vector3 position = _rect.position;
1608 _rect._SetAnchor((anchor == RectPosition.Auto) ? _rect.GetAnchor() : anchor);
1609 _rect.position = position;
1610 }

◆ SetAnchor() [2/2]

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

Definition at line 1565 of file ClassExtension.cs.

1566 {
1567 r.anchorMin = new Vector2(minX, minY);
1568 r.anchorMax = new Vector2(maxX, maxY);
1569 }

◆ SetBit()

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

Definition at line 81 of file ClassExtension.cs.

82 {
83 if (!value)
84 {
85 return Convert.ToByte(pByte & ~(1 << bitNo));
86 }
87 return Convert.ToByte(pByte | (1 << bitNo));
88 }

◆ SetEulerAngles()

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

Definition at line 1873 of file ClassExtension.cs.

1874 {
1875 vector3.Set(x, y, z);
1876 transform.eulerAngles = vector3;
1877 }

References vector3.

◆ SetEulerAnglesX()

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

Definition at line 1879 of file ClassExtension.cs.

1880 {
1881 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1882 transform.eulerAngles = vector3;
1883 }

References vector3.

◆ SetEulerAnglesY()

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

Definition at line 1885 of file ClassExtension.cs.

1886 {
1887 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1888 transform.eulerAngles = vector3;
1889 }

References vector3.

◆ SetEulerAnglesZ()

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

Definition at line 1891 of file ClassExtension.cs.

1892 {
1893 vector3.Set(transform.localEulerAngles.x, transform.localEulerAngles.y, z);
1894 transform.eulerAngles = vector3;
1895 }

References vector3.

◆ SetField< T >()

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

Definition at line 234 of file ClassExtension.cs.

235 {
236 o.GetType().GetField(name).SetValue(o, value);
237 }

◆ SetLayerRecursively()

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

Definition at line 1335 of file ClassExtension.cs.

1336 {
1337 obj.layer = layer;
1338 foreach (Transform item in obj.transform)
1339 {
1340 item.gameObject.SetLayerRecursively(layer);
1341 }
1342 }

References item.

◆ SetListener()

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

Definition at line 1242 of file ClassExtension.cs.

1243 {
1244 e.RemoveAllListeners();
1245 e.AddListener(delegate
1246 {
1247 action();
1248 });
1249 }

References Button.

◆ SetLocalEulerAngles()

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

Definition at line 1921 of file ClassExtension.cs.

1922 {
1923 vector3.Set(x, y, z);
1924 transform.localEulerAngles = vector3;
1925 }

References vector3.

◆ SetLocalEulerAnglesX()

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

Definition at line 1927 of file ClassExtension.cs.

1928 {
1929 vector3.Set(x, transform.localEulerAngles.y, transform.localEulerAngles.z);
1930 transform.localEulerAngles = vector3;
1931 }

References vector3.

◆ SetLocalEulerAnglesY()

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

Definition at line 1933 of file ClassExtension.cs.

1934 {
1935 vector3.Set(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
1936 transform.localEulerAngles = vector3;
1937 }

References vector3.

◆ SetLocalEulerAnglesZ()

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

Definition at line 1939 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalPosition()

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

Definition at line 1777 of file ClassExtension.cs.

1778 {
1779 vector3.Set(x, y, z);
1780 transform.localPosition = vector3;
1781 }

References vector3.

◆ SetLocalPositionX()

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

Definition at line 1783 of file ClassExtension.cs.

1784 {
1785 vector3.Set(x, transform.localPosition.y, transform.localPosition.z);
1786 transform.localPosition = vector3;
1787 }

References vector3.

◆ SetLocalPositionY()

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

Definition at line 1789 of file ClassExtension.cs.

1790 {
1791 vector3.Set(transform.localPosition.x, y, transform.localPosition.z);
1792 transform.localPosition = vector3;
1793 }

References vector3.

◆ SetLocalPositionZ()

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

Definition at line 1795 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScale()

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

Definition at line 1825 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleX()

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

Definition at line 1831 of file ClassExtension.cs.

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

References vector3.

◆ SetLocalScaleY()

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

Definition at line 1837 of file ClassExtension.cs.

1838 {
1839 vector3.Set(transform.localScale.x, y, transform.localScale.z);
1840 transform.localScale = vector3;
1841 }

References vector3.

◆ SetLocalScaleZ()

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

Definition at line 1843 of file ClassExtension.cs.

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

References vector3.

◆ SetNavigation()

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

Definition at line 1083 of file ClassExtension.cs.

1084 {
1085 if (!a || !b)
1086 {
1087 return;
1088 }
1089 Selectable component = a.GetComponent<Selectable>();
1090 Selectable component2 = b.GetComponent<Selectable>();
1091 if ((bool)component && (bool)component2)
1092 {
1093 Navigation navigation = component.navigation;
1094 Navigation navigation2 = component2.navigation;
1095 if (vertical)
1096 {
1097 navigation.selectOnUp = component2;
1098 navigation2.selectOnDown = component;
1099 }
1100 else
1101 {
1102 navigation.selectOnLeft = component2;
1103 navigation2.selectOnRight = component;
1104 }
1105 component.navigation = navigation;
1106 component2.navigation = navigation2;
1107 }
1108 }

◆ SetOnClick()

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

Definition at line 1233 of file ClassExtension.cs.

1234 {
1235 b.onClick.RemoveAllListeners();
1236 b.onClick.AddListener(delegate
1237 {
1238 action();
1239 });
1240 }

◆ SetPivot()

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

Definition at line 1560 of file ClassExtension.cs.

1561 {
1562 r.pivot = new Vector2(x, y);
1563 }

◆ SetPosition()

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

Definition at line 1729 of file ClassExtension.cs.

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

References vector3.

◆ SetPositionX()

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

Definition at line 1735 of file ClassExtension.cs.

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

References vector3.

◆ SetPositionY()

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

Definition at line 1741 of file ClassExtension.cs.

1742 {
1743 vector3.Set(transform.position.x, y, transform.position.z);
1744 transform.position = vector3;
1745 }

References vector3.

◆ SetPositionZ()

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

Definition at line 1747 of file ClassExtension.cs.

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

References vector3.

◆ SetProperty< T >()

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

Definition at line 244 of file ClassExtension.cs.

245 {
246 o.GetType().GetProperty(name).SetValue(o, value);
247 }

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

1550 {
1551 r.SetPivot(pivotX, pivotY);
1552 r.SetAnchor(minX, minY, maxX, maxY);
1553 if (w != -1f)
1554 {
1555 r.sizeDelta = new Vector2(w, h);
1556 }
1557 r.anchoredPosition = new Vector2((x == -1f) ? r.anchoredPosition.x : x, (y == -1f) ? r.anchoredPosition.y : y);
1558 }

◆ SetScale()

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

Definition at line 1655 of file ClassExtension.cs.

1656 {
1657 float x = renderer.bounds.size.x;
1658 float y = renderer.bounds.size.y;
1659 float x2 = size / x;
1660 float y2 = size / y;
1661 renderer.transform.localScale = new Vector3(x2, y2, 1f);
1662 }

◆ SetSlider() [1/2]

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

Definition at line 1256 of file ClassExtension.cs.

1257 {
1258 slider.SetSlider(value, action, -1, -1, notify);
1259 }

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

1262 {
1263 slider.onValueChanged.RemoveAllListeners();
1264 slider.onValueChanged.AddListener(delegate(float a)
1265 {
1266 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(a);
1267 });
1268 if (min != -1)
1269 {
1270 slider.minValue = min;
1271 slider.maxValue = max;
1272 }
1273 if (notify)
1274 {
1275 slider.value = value;
1276 }
1277 else
1278 {
1279 slider.SetValueWithoutNotify(value);
1280 }
1281 slider.GetComponentInChildren<Text>(includeInactive: true).text = action(value);
1282 }

◆ SetTag()

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

Definition at line 955 of file ClassExtension.cs.

956 {
957 s = ((!enable) ? s.RemoveTag(id, splitter) : s.AddTag(id, splitter));
958 return s;
959 }

◆ SetY()

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

Definition at line 1705 of file ClassExtension.cs.

1706 {
1707 v.y = a;
1708 return v;
1709 }

◆ SetZ()

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

Definition at line 1699 of file ClassExtension.cs.

1700 {
1701 v.z = a;
1702 return v;
1703 }

◆ Shuffle< TValue >()

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

Definition at line 349 of file ClassExtension.cs.

350 {
351 int num = list.Count;
352 while (num > 1)
353 {
354 int index = Rand._random.Next(num);
355 num--;
356 TValue value = list[num];
357 list[num] = list[index];
358 list[index] = value;
359 }
360 return list;
361 }
static Random _random
Definition: Rand.cs:9

References Rand._random.

◆ Sort< T >()

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

Definition at line 249 of file ClassExtension.cs.

250 {
251 if (list is List<T>)
252 {
253 ((List<T>)list).Sort(comparison);
254 return;
255 }
256 List<T> list2 = new List<T>(list);
257 list2.Sort(comparison);
258 for (int i = 0; i < list.Count; i++)
259 {
260 list[i] = list2[i];
261 }
262 }

◆ SplitByNewline()

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

Definition at line 644 of file ClassExtension.cs.

645 {
646 if (string.IsNullOrEmpty(text))
647 {
648 return new string[0];
649 }
650 return text.Split(new string[3] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
651 }

◆ SplitNewline()

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

Definition at line 829 of file ClassExtension.cs.

830 {
831 return str.Split(Environment.NewLine.ToCharArray());
832 }

◆ SplitToInts()

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

Definition at line 818 of file ClassExtension.cs.

819 {
820 string[] array = str.Split(separator);
821 int[] array2 = new int[array.Length];
822 for (int i = 0; i < array.Length; i++)
823 {
824 array2[i] = int.Parse(array[i]);
825 }
826 return array2;
827 }

◆ StripBrackets()

static string ClassExtension.StripBrackets ( this string  str)
inlinestatic

Definition at line 776 of file ClassExtension.cs.

777 {
778 HashSet<char> brackets = new HashSet<char> { '"', '「', '」', '“', '”' };
779 return string.Concat(str.Where((char c) => !brackets.Contains(c)));
780 }

◆ StripLastPun()

static string ClassExtension.StripLastPun ( this string  str)
inlinestatic

Definition at line 730 of file ClassExtension.cs.

731 {
732 if (str != null)
733 {
734 return str.TrimEnd(Lang.words.period);
735 }
736 return str;
737 }
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 739 of file ClassExtension.cs.

740 {
741 StringBuilder stringBuilder = new StringBuilder();
742 foreach (char c in str)
743 {
744 if (c == Lang.words.comma)
745 {
746 if (stripComma)
747 {
748 if (insertSpaceForComma)
749 {
750 stringBuilder.Append('\u3000');
751 }
752 }
753 else
754 {
755 stringBuilder.Append(c);
756 }
757 }
758 else if (c != Lang.words.period)
759 {
760 stringBuilder.Append(c);
761 }
762 }
763 return stringBuilder.ToString();
764 }
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 1223 of file ClassExtension.cs.

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

References $.

◆ TagColor() [1/2]

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

Definition at line 935 of file ClassExtension.cs.

936 {
937 return "<color=" + c.ToHex() + ">" + s + "</color>";
938 }

◆ TagColor() [2/2]

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

Definition at line 930 of file ClassExtension.cs.

931 {
932 return s + "<color=" + c.ToHex() + ">" + txt + "</color>";
933 }

◆ TagSize() [1/2]

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

Definition at line 945 of file ClassExtension.cs.

946 {
947 return "<size=" + size + ">" + s + "</size>";
948 }

◆ TagSize() [2/2]

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

Definition at line 940 of file ClassExtension.cs.

941 {
942 return s + "<size=" + size + ">" + txt + "</size>";
943 }

◆ ToBytes()

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

Definition at line 69 of file ClassExtension.cs.

70 {
71 byte[] array = new byte[(bits.Length - 1) / 8 + 1];
72 bits.CopyTo(array, 0);
73 return array;
74 }

◆ ToColor()

static Color ClassExtension.ToColor ( this string  s)
inlinestatic

Definition at line 1195 of file ClassExtension.cs.

1196 {
1197 Color color = Color.white;
1198 ColorUtility.TryParseHtmlString("#" + s, out color);
1199 return color;
1200 }

References Color.

◆ ToDictionary< T >()

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

Definition at line 610 of file ClassExtension.cs.

611 {
612 dic = new Dictionary<string, T>();
613 for (int i = 0; i < list.Count; i++)
614 {
615 dic.Add(list[i].name, list[i].value);
616 }
617 }

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

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

Definition at line 135 of file ClassExtension.cs.

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

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

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

Definition at line 140 of file ClassExtension.cs.

141 {
142 return (T)Enum.ToObject(typeof(T), value);
143 }

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

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

Definition at line 145 of file ClassExtension.cs.

146 {
147 return (T)Enum.Parse(typeof(T), value, ignoreCase);
148 }

◆ ToField< T >()

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

Definition at line 214 of file ClassExtension.cs.

215 {
216 return (T)o.GetType().GetField(s).GetValue(o);
217 }

◆ ToFloat()

static float ClassExtension.ToFloat ( this string  str)
inlinestatic

Definition at line 711 of file ClassExtension.cs.

712 {
713 float result = 0f;
714 try
715 {
716 if (!float.TryParse(str, out result))
717 {
718 Debug.Log("exception: ToFlat1" + str);
719 result = 1f;
720 }
721 }
722 catch
723 {
724 Debug.Log("exception: ToFlat2" + str);
725 result = 1f;
726 }
727 return result;
728 }

References Debug.

◆ ToFormat() [1/2]

static string ClassExtension.ToFormat ( this int  a)
inlinestatic

Definition at line 898 of file ClassExtension.cs.

899 {
900 return $"{a:#,0}";
901 }

References $.

◆ ToFormat() [2/2]

static string ClassExtension.ToFormat ( this long  a)
inlinestatic

Definition at line 903 of file ClassExtension.cs.

904 {
905 return $"{a:#,0}";
906 }

References $.

◆ ToggleActive()

static void ClassExtension.ToggleActive ( this Component  c)
inlinestatic

Definition at line 1308 of file ClassExtension.cs.

1309 {
1310 c.SetActive(!c.gameObject.activeSelf);
1311 }

◆ ToggleKeyword()

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

Definition at line 1969 of file ClassExtension.cs.

1970 {
1971 if (enable)
1972 {
1973 m.EnableKeyword(id);
1974 }
1975 else
1976 {
1977 m.DisableKeyword(id);
1978 }
1979 }

◆ ToHex()

static string ClassExtension.ToHex ( this Color  c)
inlinestatic

Definition at line 1228 of file ClassExtension.cs.

1229 {
1230 return $"#{(int)(c.r * 255f):X2}{(int)(c.g * 255f):X2}{(int)(c.b * 255f):X2}";
1231 }

References $.

◆ ToInt() [1/2]

static int ClassExtension.ToInt ( this string  str)
inlinestatic

Definition at line 693 of file ClassExtension.cs.

694 {
695 if (int.TryParse(str, out var result))
696 {
697 return result;
698 }
699 return 0;
700 }

◆ ToInt() [2/2]

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

Definition at line 682 of file ClassExtension.cs.

683 {
684 FieldInfo field = type.GetField(str, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
685 if (field == null)
686 {
687 Debug.LogError("Field is null:" + str + "/" + type);
688 return -1;
689 }
690 return (int)field.GetValue(null);
691 }

References Debug.

◆ ToInt2()

static int ClassExtension.ToInt2 ( this float  a)
inlinestatic

Definition at line 100 of file ClassExtension.cs.

101 {
102 return (int)(a * 100f);
103 }

◆ ToInt3()

static int ClassExtension.ToInt3 ( this float  a)
inlinestatic

Definition at line 90 of file ClassExtension.cs.

91 {
92 return (int)(a * 1000f);
93 }

◆ ToInt< T >()

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

Definition at line 677 of file ClassExtension.cs.

678 {
679 return str.ToInt(typeof(T));
680 }

◆ ToLong()

static long ClassExtension.ToLong ( this string  str)
inlinestatic

Definition at line 702 of file ClassExtension.cs.

703 {
704 if (long.TryParse(str, out var result))
705 {
706 return result;
707 }
708 return 0L;
709 }

◆ ToShortNumber()

static string ClassExtension.ToShortNumber ( this int  a)
inlinestatic

Definition at line 855 of file ClassExtension.cs.

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

◆ ToText()

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

Definition at line 908 of file ClassExtension.cs.

909 {
910 object obj;
911 if (!(a == 0 && skipIfZero))
912 {
913 if (a >= 0)
914 {
915 return "+" + a;
916 }
917 obj = a.ToString();
918 if (obj == null)
919 {
920 return "";
921 }
922 }
923 else
924 {
925 obj = "";
926 }
927 return (string)obj;
928 }

◆ ToTitleCase()

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

Definition at line 1035 of file ClassExtension.cs.

1036 {
1037 if (!Lang.setting.capitalize)
1038 {
1039 return s;
1040 }
1041 char[] array = s.ToCharArray();
1042 bool flag = true;
1043 for (int i = 0; i < array.Length; i++)
1044 {
1045 if (flag)
1046 {
1047 array[i] = char.ToUpper(array[i]);
1048 flag = false;
1049 }
1050 if (!wholeText)
1051 {
1052 break;
1053 }
1054 if (array[i] == ' ')
1055 {
1056 flag = true;
1057 }
1058 }
1059 return new string(array);
1060 }
bool capitalize
Definition: LangSetting.cs:34

References LangSetting.capitalize, and Lang.setting.

◆ ToType()

static Type ClassExtension.ToType ( this string  value)
inlinestatic

Definition at line 150 of file ClassExtension.cs.

151 {
152 return Type.GetType("Elona." + value + ", Assembly-CSharp");
153 }

◆ ToVector2()

static Vector2 ClassExtension.ToVector2 ( this Vector3  self)
inlinestatic

Definition at line 1650 of file ClassExtension.cs.

1651 {
1652 return new Vector2(self.x, self.z);
1653 }

◆ TrimNewLines()

static string ClassExtension.TrimNewLines ( this string  text)
inlinestatic

Definition at line 809 of file ClassExtension.cs.

810 {
811 while (text.EndsWith(Environment.NewLine))
812 {
813 text = text.Substring(0, text.Length - Environment.NewLine.Length);
814 }
815 return text;
816 }

◆ TryAddExtension()

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

Definition at line 782 of file ClassExtension.cs.

783 {
784 if (!s.Contains("." + ext))
785 {
786 return s + "." + ext;
787 }
788 return s;
789 }

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

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

Definition at line 285 of file ClassExtension.cs.

286 {
287 if (index >= array.Count)
288 {
289 return default(TValue);
290 }
291 return array[index];
292 }

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

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

Definition at line 264 of file ClassExtension.cs.

265 {
266 if (array.Count != 0)
267 {
268 if (index >= array.Count)
269 {
270 if (defIndex != -1)
271 {
272 if (array.Count <= defIndex)
273 {
274 return array[Mathf.Max(0, array.Count - 1)];
275 }
276 return array[defIndex];
277 }
278 return array[Mathf.Max(0, array.Count - 1)];
279 }
280 return array[Math.Max(0, index)];
281 }
282 return default(TValue);
283 }

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

374 {
375 TValue value = default(TValue);
376 if (key != null && source.TryGetValue(key, out value))
377 {
378 return value;
379 }
380 return source[key_fallback];
381 }

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

364 {
365 TValue value = default(TValue);
366 if (key != null && source.TryGetValue(key, out value))
367 {
368 return value;
369 }
370 return fallback;
371 }

◆ Within() [1/2]

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

Definition at line 174 of file ClassExtension.cs.

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

◆ Within() [2/2]

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

Definition at line 165 of file ClassExtension.cs.

166 {
167 if (v - v2 >= range)
168 {
169 return v - v2 < -range;
170 }
171 return true;
172 }

Member Data Documentation

◆ pluralizer

IPluralize ClassExtension.pluralizer = new Pluralizer()
static

Definition at line 18 of file ClassExtension.cs.

Referenced by langPlural(), and Pluralize().

◆ vector3


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