-
Notifications
You must be signed in to change notification settings - Fork 12
Common
DucNV_2000 edited this page Mar 1, 2024
·
33 revisions
-
IsInteger
checks the input value is an integer or not
static bool IsInteger(float value)
-
GetNumberInAString
Gets the first number that appears in the input string
static int GetNumberInAString(string str)
// exp: str = ab234dc => result: 234
// exp: str = ab23df45 => result: 23
-
CallActionAndClean
execute the call action and remove the original reference
static void CallActionAndClean(ref Action action)
-
IsNullOrEmpty
check null or empty
static bool IsNullOrEmpty<T>(this List<T> source) // Check for null or empty list
static bool IsNullOrEmpty<T>(this T[] source) // Check for null or empty array
static bool IsNullOrEmpty<TKey, TValue>(this Dictionary<TKey, TValue> source) // Check for null or empty dictionary
Shuffle
static void Shuffle<T>(this T[] source) // shuffle the elements in the array
static void Shuffle<T>(this List<T> source) // shuffle the elements in the list
static IDictionary<T1, T2> Shuffle<T1, T2>(this IDictionary<T1, T2> source) // shuffle the elements in the dictionary
MakeDictionary
static IDictionary<TKey, TValue> MakeDictionary<TKey, TValue>(this TKey[] keys, TValue[] values) // Make a dictionary from an array of keys and an array of values
static IDictionary<TKey, TValue> MakeDictionary<TKey, TValue>(this IList<TKey> keys, IList<TValue> values) // Make a dictionary from a list of keys and an array of values
PickRandom
static T PickRandom<T>(this T[] collection) // Randomly select an element of the array
static T PickRandom<T>(this List<T> collection) // Randomly select an element of the list
PickRandomAndIndex
static (T, int) PickRandomAndIndex<T>(this T[] collection) // Randomly select an element and index of the array
(T, int) PickRandomWithIndex<T>(this List<T> collection) // Randomly select an element and index of the list
InternetConnection
static IEnumerator InternetConnection(Action<bool> action)
// if request internet success => action(true)
// if request internet fail => action(false)
static void CheckInternetConnection(Action actionConnected, Action actionDisconnected)
// actionConnected => Action when connected to the internet
// actionDisconnected => Action when losing internet connection
PlayAnim
static AnimancerComponent PlayAnim(this AnimancerComponent animancerComponent, ClipTransition clip,Action _endAnim = null, float _durationFade = .2f, FadeMode mode = default)
PauseClip
// Freeze a single animation on its current frame:
static AnimancerComponent PauseClip(this AnimancerComponent animancerComponent, ClipTransition clip)
PauseAll
// Freeze all animations on their current frame
static AnimancerComponent PauseAll(this AnimancerComponent animancerComponent)
StopClip
// Stop a single animation from affecting the character and rewind it to the start
static AnimancerComponent StopClip(this AnimancerComponent animancerComponent, ClipTransition clip)
StopAll
// Stop all animations from affecting the character and rewind them to the start
static AnimancerComponent StopAll(this AnimancerComponent animancerComponent)
Example
public AnimancerComponent animancerComponent;
public ClipTransition clip;
public void PlayAnimation()
{
animancerComponent.PlayAnim(clip);
}
public void PauseAnimation()
{
animancerComponent.PauseClip(clip);
}
public void PauseAllAnimation()
{
animancerComponent.PauseAll();
}
public void StopAnimation()
{
animancerComponent.StopClip(clip);
}
public void StopAllAnimation()
{
animancerComponent.StopAll();
}
-
IgnoreCollisionListColliderWithCollider
Ignore Collision between a Collider and a list of Collider
static void IgnoreCollisionListColliderWithCollider(List<Collider> _listCollider, Collider _collider)
static void IgnoreCollisionListColliderWithCollider(Collider _collider, List<Collider> _listCollider)
-
IgnoreCollisionListColliderWithListCollider
Ignore Collision between a list of Collider and a list of Collider
static void IgnoreCollisionListColliderWithListCollider(List<Collider> _listCollider1, List<Collider> _listCollider2)
-
IgnoreCollision2DListColliderWithCollider
Ignore Collision 2D between a Collider and a list of Collider
static void IgnoreCollision2DListColliderWithCollider(List<Collider2D> _listCollider, Collider2D _collider)
static void IgnoreCollision2DListColliderWithCollider(Collider2D _collider, List<Collider2D> _listCollider)
-
IgnoreCollision2DListColliderWithListCollider
Ignore Collision 2D between a list of Collider and a list of Collider
static void IgnoreCollision2DListColliderWithListCollider(List<Collider2D> _listCollider1, List<Collider2D> _listCollider2)