Releases: AndrzejKebab/UtilityLibrary
Releases · AndrzejKebab/UtilityLibrary
Release list
Utility Library v2.5.0
Full Changelog: 2.4.0...2.5.0
Utility Library v2.4.0
Full Changelog: 2.3.0...2.4.0
Utility Library v2.3.0
Full Changelog: 2.2.0...2.3.0
Utility Library v.2.2.0
[2.2.0] - 31.01.2024
Full Changelog: 2.1.0...2.2.0
Utility Library v2.1.0
[2.1.0] - 24-01-2024
Added
IList Extensions
Min / Max
Min<T>(this IList<T> list) where T : IComparable: Returns the minimum item in the list based on the IComparable interface.Min<T>(this IList<T> list, Func<T, IComparable> keyGetter) where T : IComparable: Returns the minimum item in the list based on a key selector function.Max<T>(this IList<T> list) where T : IComparable: Returns the maximum item in the list based on the IComparable interface.Max<T>(this IList<T> list, Func<T, IComparable> keyGetter) where T : IComparable: Returns the maximum item in the list based on a key selector function.
To List
ToList<T, TResult>(this IList<T> list, Func<T, TResult> selector): Converts the elements of an IList to another type and returns a List containing the converted elements.
To Dictionary
ToDictionary<TKey, T>(this IList<T> list, Func<T, TKey> getKeyFunc): Converts the elements of an IList to a Dictionary using a provided key selector function.ToDictionary<TKey, TValue, T>(this IList<T> list, Func<T, TKey> getKeyFunc, Func<T, TValue> getValueFunc): Converts the elements of an IList to a Dictionary using provided key and value selector functions.
IEnumerable Extensions
Min / Max
Min<T, TValue>(this IEnumerable<T> source, Func<T, TValue> keyGetter, out TValue minValue) where TValue : IComparable: Returns the minimum item in the source sequence based on a key selector function.Min<T, TValue>(this IEnumerable<T> source, Func<T, TValue> selector) where TValue : IComparable: Returns the minimum item in the source sequence based on a selector function.Max<T, TValue>(this IEnumerable<T> source, Func<T, TValue> keyGetter, out TValue maxValue) where TValue : IComparable<TValue>: Returns the maximum item in the source sequence based on a key selector function.Max<T, TValue>(this IEnumerable<T> source, Func<T, TValue> keyGetter) where TValue : IComparable<TValue>: Returns the maximum item in the source sequence based on a selector function.
Select
Select<T, TResult>(this IEnumerable<T> source, Func<T, TResult> selector, bool allowNull = true): Projects each element of a sequence into a new form.
Utility-Library v2.0.0
[2.0.0] - 23-01-2024
Unity.Runtime
Added
GameObject Extensions
Prefab
IsPrefab(this GameObject gameObject): Checks if the GameObject is a prefab.
HasComponent
HasComponent<T>(this GameObject gameObject): Checks if the GameObject has a specified component type.HasRigidbody(this GameObject gameObject): Checks if the GameObject has a Rigidbody component.HasAnimation(this GameObject gameObject): Checks if the GameObject has an Animation component.HasAnimator(this GameObject gameObject): Checks if the GameObject has an Animator component.
Component
TryGetComponent<T>(this GameObject gameObject, out T outComponent): Attempts to get a component of type T from the GameObject.TryGetComponentInParent<T>(this GameObject gameObject, out T outComponent): Attempts to get a component of type T from the GameObject or its ancestors.TryGetComponentInChildren<T>(this GameObject gameObject, out T outComponent): Attempts to get a component of type T from the GameObject or its descendants.GetOrAddComponent<T>(this GameObject gameObject): Gets or adds a component of type T to the GameObject.GetOrAddComponent(this GameObject gameObject, Type type): Gets or adds a component of the specified type to the GameObject.DestroyComponent<T>(this GameObject gameObject): Destroys a component of type T on the GameObject.DestroyComponent(this GameObject gameObject, Type type): Destroys a component of the specified type on the GameObject.SearchComponent<T>(this GameObject gameObject, string searchName): Searches for a component of type T with the specified name in the GameObject's descendants.FindComponentInParents<T>(this GameObject gameObject): Finds a component of type T in the GameObject's ancestors.FindComponentInParents(this GameObject gameObject, Type type): Finds a component of the specified type in the GameObject's ancestors.
Path
CreateChild(this GameObject gameObject, string pathName, char splitChar = '/'): Creates child GameObjects based on the provided path name.Path(this GameObject gameObject): Gets the path of the GameObject in the scene hierarchy.PathFull(this GameObject gameObject): Gets the full path of the GameObject in the scene hierarchy, including the GameObject's name.Root(this GameObject go): Gets the root GameObject in the hierarchy of the provided GameObject.Depth(this GameObject go): Gets the depth of the GameObject in the hierarchy.
Layer
ContainLayer(this GameObject gameObject, int otherLayerIndex): Checks if the GameObject's layer is included in a specific layer index.ContainLayer(this GameObject gameObject, LayerMask otherLayerMask): Checks if the GameObject's layer is included in a specific LayerMask.ContainLayers(this GameObject gameObject, params LayerMask[] otherLayerMasks): Checks if the GameObject's layer is included in all specified LayerMasks.ContainOneOfLayers(this GameObject gameObject, params LayerMask[] otherLayerMasks): Checks if the GameObject's layer is included in at least one of the specified LayerMasks.SetLayer(this GameObject gameObject, LayerMask layerMask): Sets the layer of the GameObject using the provided LayerMask.SetLayerRecursion(this GameObject gameObject, LayerMask layerMask): Sets the layer of the GameObject and its children using the provided LayerMask.SetLayerRecursion(this GameObject gameObject, int layerIndex): Sets the layer of the GameObject and its children using the provided layer index.
Tag
SetTag(this GameObject gameObject, string tag): Sets the tag of the GameObject.SetTagRecursion(this GameObject gameObject, string tag): Sets the tag of the GameObject and its children.
Particle
GetParticleDuration(this GameObject gameObject, bool includeChildren = true, bool includeInactive = false, bool allowLoop = false): Gets the duration of the ParticleSystem on the GameObject.
Trail Renderer
GetTrailRendererTime(this GameObject gameObject): Gets the maximum time of TrailRenderer(s) on the GameObject.
Bounds
GetBounds(this GameObject gameObject, bool includeChildren = true): Gets the bounding box of the GameObject.
MeshFilter Extensions
GetBounds(this MeshFilter meshFilter, bool includeChildren = true): Gets the bounds of the mesh filter.
ParticleSystemExtensions
GetDuration(this ParticleSystem particle, bool allowLoop = false): Retrieves the duration. Returns -1 ifallowLoopis false and the system is looping.GetMaxValue(this ParticleSystem.MinMaxCurve minMaxCurve): Obtains the maximum value.GetMinValue(this ParticleSystem.MinMaxCurve minMaxCurve): Gets the minimum value.
Renderer Extensions
Visibility
IsVisible(this Renderer renderer, Camera camera): Checks if the renderer is visible from the specified camera.
Bounds
GetBounds(this Renderer renderer, bool includeChildren = true): Gets the bounds of the renderer. IfincludeChildrenis true, the bounds encapsulate the bounds of child renderers.
Material
GetMaterial(this Renderer renderer, int materialIndex): Gets the material at the specified index. Returns null if the index is out of range.
LayerMask Extensions
Containment
Contains(this LayerMask layerMask, LayerMask otherLayerMask): Checks if the layer mask contains the other layer mask.Contains(this LayerMask layerMask, int layerIndex): Checks if the layer mask contains the specified layer index.
Information Retrieval
GetLayerIndex(this LayerMask layerMask): Gets the layer index of the layer mask. Returns -1 if an error occurred.Inverse(this LayerMask layerMask): Inverts the layer mask.
Modification
AddToMask(this LayerMask layerMask, params string[] name): Adds the specified layers to the layer mask.RemoveFromMask(this LayerMask layerMask, params string[] name): Removes the specified layers from the layer mask.
Conversion
MaskToNames(this LayerMask layerMask): Converts the layer mask to an array of layer names.MaskToString(this LayerMask layerMask): Converts the layer mask to a string.MaskToString(this LayerMask layerMask, string delimiter): Converts the layer mask to a string with the specified delimiter.internal static LayerMask NameToMask(params string[] layerNames): Converts the specified layer names to a layer mask.
AnimationCurve Extensions
Looping
IsLooping(this AnimationCurve animationCurve): Checks if the animation curve is looping.
Value Retrieval
GetMaxValue(this AnimationCurve animationCurve): Gets the maximum value of the animation curve.GetMinValue(this AnimationCurve animationCurve): Gets the minimum value of the animation curve.
Modification
Reverse(this AnimationCurve animationCurve): Reverses the animation curve.
Utility Library v1.3.0
[1.3.0] - 23-01-2024
Added
StringExtensions
IsMatchmethod to check if a string matches the given pattern.IsMatchmethod to check if a string matches the given Regex.Matchmethod to return the first match of the pattern in the string.Matchmethod to return the first match of the Regex in the string.Matchesmethod to return all matches of the pattern in the string.Matchesmethod to return all matches of the pattern in the string with the specified options.MatchValuesmethod to return all match values of the pattern in the string.MatchValuesmethod to return all match values of the pattern in the string with the specified options.
GenericExtensions
Null / Empty
IsNullmethod to check if the value is null.IsNotNullmethod to check if the value is not null.IsEmptymethod to check if the value is the default value for its type.IsNotEmptymethod to check if the value is not the default value for its type.ToNullablemethod to convert the value to a nullable type.
Equal
EqualsAnymethod to check if the value is equal to any of the provided values.EqualsNonemethod to check if the value is not equal to any of the provided values.
Flag
HasFlagsmethod to check if the value has all the specified flags.
ObjectExtensions
Null
IsNullmethod to check if the object is null.IsNotNullmethod to check if the object is not null.
Type
CastType<T>method to cast the object to the specified type.CastTypemethod to cast the object to the specified type.ConvertTo<T>method to convert the object to the specified type.CanConvertTo<T>method to check if the object can be converted to the specified type.
As
AsStringmethod to convert the object to a string.AsStringmethod to convert the object to a string using the specified format provider.AsInvariantStringmethod to convert the object to a string using the invariant culture.AsIntmethod to convert the object to an integer.AsLongmethod to convert the object to a long.AsShortmethod to convert the object to a short.AsFloatmethod to convert the object to a float.AsDoublemethod to convert the object to a double.AsDecimalmethod to convert the object to a decimal.
TaskAwaiterExtensions
GetAwaiter(this TimeSpan timeSpan)method to get aTaskAwaiterthat completes after a specified time period.GetAwaiter(this int seconds)method to get aTaskAwaiterthat completes after a specified number of seconds.GetAwaiter(this float seconds)method to get aTaskAwaiterthat completes after a specified number of seconds.
IList Extensions
Random<T>(this IList<T> list)method to get a random item from the list.Random<T>(this IList<T> list, Predicate<T> predicate)method to get a random item from the list that matches a predicate.Random<T>(this IList<T> list, int count, bool allowRepeat = false)method to get a specified number of random items from the list.Random<T>(this IList<T> list, Func<T, int> weightGetter)method to get a random item from the list, with the probability of choosing each item proportional to its weight.Random<T>(this IList<T> list, Func<T, int> weightGetter, int count)method to get a specified number of random items from the list, with the probability of choosing each item proportional to its weight.Random<T>(this IList<T> list, Func<T, float> weightGetter)method to get a random item from the list, with the probability of choosing each item proportional to its weight.Random<T>(this IList<T> list, Func<T, float> weightGetter, int count)method to get a specified number of random items from the list, with the probability of choosing each item proportional to its weight.
Utility Library v1.2.0
[1.2.0] - 23-01-2024
Added
ArrayExtensions
Sortmethod to sort the elements in the entire array using the specified comparison.Sortmethod to sort a range of elements in the array using the specified comparer.RandSortmethod to sort the elements in the array in random order.
Utility Library v.1.1.0
[1.1.0] - 22-01-2024
Added
BoolExtensions
-
Andextension method:- Overloads:
And(this bool boolean, Func<bool> other): Performs a logical AND operation on the first boolean value and a function returning a boolean.And<T>(this bool boolean, Func<T, bool> other, T value): Performs a logical AND operation on the first boolean value and a function taking one parameter and returning a boolean.And<T1, T2>(this bool boolean, Func<T1, T2, bool> other, T1 value1, T2 value2): Performs a logical AND operation on the first boolean value and functions taking two parameters and returning a boolean.And<T1, T2, T3>(this bool boolean, Func<T1, T2, T3, bool> other, T1 value1, T2 value2, T3 value3): Performs a logical AND operation on the first boolean value and functions taking three parameters and returning a boolean.And<T1, T2, T3, T4>(this bool boolean, Func<T1, T2, T3, T4, bool> other, T1 value1, T2 value2, T3 value3, T4 value4): Performs a logical AND operation on the first boolean value and functions taking four parameters and returning a boolean.And<T1, T2, T3, T4, T5>(this bool boolean, Func<T1, T2, T3, T4, T5, bool> other, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5): Performs a logical AND operation on the first boolean value and functions taking five parameters and returning a boolean.
- Overloads:
-
AndNotextension method:- Overloads:
AndNot(this bool boolean, Func<bool> other): Performs a logical AND NOT operation on the first boolean value and a function returning a boolean.AndNot<T>(this bool boolean, Func<T, bool> other, T value): Performs a logical AND NOT operation on the first boolean value and a function taking one parameter and returning a boolean.AndNot<T1, T2>(this bool boolean, Func<T1, T2, bool> other, T1 value1, T2 value2): Performs a logical AND NOT operation on the first boolean value and functions taking two parameters and returning a boolean.AndNot<T1, T2, T3>(this bool boolean, Func<T1, T2, T3, bool> other, T1 value1, T2 value2, T3 value3): Performs a logical AND NOT operation on the first boolean value and functions taking three parameters and returning a boolean.AndNot<T1, T2, T3, T4>(this bool boolean, Func<T1, T2, T3, T4, bool> other, T1 value1, T2 value2, T3 value3, T4 value4): Performs a logical AND NOT operation on the first boolean value and functions taking four parameters and returning a boolean.AndNot<T1, T2, T3, T4, T5>(this bool boolean, Func<T1, T2, T3, T4, T5, bool> other, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5): Performs a logical AND NOT operation on the first boolean value and functions taking five parameters and returning a boolean.
- Overloads:
-
Orextension method:- Overloads:
Or(this bool boolean, Func<bool> other): Performs a logical OR operation on the first boolean value and a function returning a boolean.Or<T>(this bool boolean, Func<T, bool> other, T value): Performs a logical OR operation on the first boolean value and a function taking one parameter and returning a boolean.Or<T1, T2>(this bool boolean, Func<T1, T2, bool> other, T1 value1, T2 value2): Performs a logical OR operation on the first boolean value and functions taking two parameters and returning a boolean.Or<T1, T2, T3>(this bool boolean, Func<T1, T2, T3, bool> other, T1 value1, T2 value2, T3 value3): Performs a logical OR operation on the first boolean value and functions taking three parameters and returning a boolean.Or<T1, T2, T3, T4>(this bool boolean, Func<T1, T2, T3, T4, bool> other, T1 value1, T2 value2, T3 value3, T4 value4): Performs a logical OR operation on the first boolean value and functions taking four parameters and returning a boolean.Or<T1, T2, T3, T4, T5>(this bool boolean, Func<T1, T2, T3, T4, T5, bool> other, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5): Performs a logical OR operation on the first boolean value and functions taking five parameters and returning a boolean.
- Overloads:
-
OrNotextension method:- Overloads:
OrNot(this bool boolean, Func<bool> other): Performs a logical OR NOT operation on the first boolean value and a function returning a boolean.OrNot<T>(this bool boolean, Func<T, bool> other, T value): Performs a logical OR NOT operation on the first boolean value and a function taking one parameter and returning a boolean.OrNot<T1, T2>(this bool boolean, Func<T1, T2, bool> other, T1 value1, T2 value2): Performs a logical OR NOT operation on the first boolean value and functions taking two parameters and returning a boolean.OrNot<T1, T2, T3>(this bool boolean, Func<T1, T2, T3, bool> other, T1 value1, T2 value2, T3 value3): Performs a logical OR NOT operation on the first boolean value and functions taking three parameters and returning a boolean.OrNot<T1, T2, T3, T4>(this bool boolean, Func<T1, T2, T3, T4, bool> other, T1 value1, T2 value2, T3 value3, T4 value4): Performs a logical OR NOT operation on the first boolean value and functions taking four parameters and returning a boolean.OrNot<T1, T2, T3, T4, T5>(this bool boolean, Func<T1, T2, T3, T4, T5, bool> other, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5): Performs a logical OR NOT operation on the first boolean value and functions taking five parameters and returning a boolean.
- Overloads:
Utility Library v1.0.0
Changelog
[1.0.0] - 21-01-2024
Added
ArrayExtensions
IsNullOrEmptyextension method to check if an array is null or empty.IsEmptyextension method to check if an array is empty.WithinIndexextension methods to check if an index is within the bounds of the array or a specific dimension.Swapextension method to swap elements at specified indices in the array.Findextension methods to find elements in the array based on a given predicate.IndexOfextension method to find the index of a specified object in a one-dimensional array.CombineArrayextension method to combine two arrays into one.ClearAtextension methods to clear the value at a specified index in the array.ClearAllextension methods to clear all values in the array.BlockCopyextension methods to copy elements from a source array to a new array, either of a specified length or padded to the length.AsObjectsextension method to convert an array of a specific type to an array of objects.Firstextension method to get the first element of an array, or a default value if the array contains no elements.Firstextension method to get the first element of an array that satisfies a specified condition, or a default value if no such element is found.Lastextension method to get the last element of an array, or a default value if the array contains no elements.Lastextension method to get the last element of an array that satisfies a specified condition, or a default value if no such element is found.Containsextension method to determine whether an array contains a specific value.Containsextension method to determine whether an array contains elements that satisfy a specified condition.
ArrayListExtensions
IsNullOrEmptyextension method to check if an ArrayList is null or empty.IsEmptyextension method to check if an ArrayList is empty.FirstandLastextension methods to retrieve the first and last elements of the ArrayList.
BoolExtensions
Andextension method to perform a logical AND operation on two boolean values.Orextension method to perform a logical OR operation on two boolean values.AndNotextension method to perform a logical AND operation on the first boolean value and the logical NOT of the second boolean value.OrNotextension method to perform a logical OR operation on the first boolean value and the logical NOT of the second boolean value.Xorextension method to perform a logical XOR operation on two boolean values.
ByteExtensions
IsEvenextension method to check if a byte value is even.IsOddextension method to check if a byte value is odd.ToIntextension method to convert a byte array to an integer.ToLongextension method to convert a byte array to a long.ToCharextension method to convert a byte array to a char.ToFloatextension method to convert a byte array to a float.ToDoubleextension method to convert a byte array to a double.ToBooleanextension method to convert a byte array to a boolean.ToStringextension method to convert a byte array to a string.ToType<T>extension method to convert a byte array to a specified type using binary deserialization.
CharExtensions
IsControlextension method to check if a character is a control character.IsDigitextension method to check if a character is a digit.IsHighSurrogateextension method to check if a character is a high surrogate.IsLowSurrogateextension method to check if a character is a low surrogate.IsPunctuationextension method to check if a character is a punctuation symbol.IsLetterextension method to check if a character is a letter.IsLetterOrDigitextension method to check if a character is a letter or a digit.IsSymbolextension method to check if a character is a symbol.IsSeparatorextension method to check if a character is a separator.IsSurrogateextension method to check if a character is a surrogate.IsLowerextension method to check if a character is a lowercase letter.IsUpperextension method to check if a character is an uppercase letter.ToLowerextension method to convert a character to lowercase.ToUpperextension method to convert a character to uppercase.IsWhiteSpaceextension method to check if a character is white space.
DecimalExtensions
Absextension method to calculate the absolute value of a decimal.Absextension method to calculate the absolute values for each element in an enumerable collection of decimals.RoundDecimalPointsextension method to round a decimal value to a specified number of decimal points.RoundToTwoDecimalPointsextension method to round a decimal value to two decimal points.
DoubleExtensions
Absextension method to calculate the absolute value of a double.Absextension method to calculate the absolute values for each element in an enumerable collection of doubles.RoundDecimalPointsextension method to round a double value to a specified number of decimal points.RoundToTwoDecimalPointsextension method to round a double value to two decimal points.IsInRangeextension method to determine whether a double value is within a specified range.InRangeextension method to return a double value if it is within a specified range; otherwise, returns a default value.ToDaysextension method to convert a double value to a TimeSpan representing days.ToHoursextension method to convert a double value to a TimeSpan representing hours.ToMinutesextension method to convert a double value to a TimeSpan representing minutes.ToSecondsextension method to convert a double value to a TimeSpan representing seconds.ToMillisecondsextension method to convert a double value to a TimeSpan representing milliseconds.
EnumExtensions
ClearFlagmethod to clear a specific flag from an enumeration value.ClearFlagsmethod to clear multiple flags from an enumeration value.SetFlagmethod to set a specific flag in an enumeration value.SetFlagsmethod to set multiple flags in an enumeration value.ContainsFlagmethod to check if an enumeration value contains a specific flag.FromStringmethod to convert a string to an enumeration value.TryParsemethod to try converting a string to an enumeration value.EnumIndexmethod to get the index of a specific integer value in an enumeration.EnumIndexmethod to get the index of a specific byte value in an enumeration.
FloatExtensions
Absmethod to calculate the absolute value of a float.Absmethod to calculate the absolute values for each element in an enumerable collection of floats.ClampMin0method to clamp a float value to a minimum of 0.ClampMinmethod to clamp a float value to a specified minimum.ClampMax0method to clamp a float value to a maximum of 0.ClampMaxmethod to clamp a float value to a specified maximum.Clamp01method to clamp a float value between 0 and 1.Clampmethod to clamp a float value to a specified range.RoundDecimalPointsmethod to round a float value to a specified number of decimal points.RoundToTwoDecimalPointsmethod to round a float value to two decimal points.IsInRangemethod to determine whether a float value is within a specified range.InRangemethod to return a float value if it is within a specified range; otherwise, returns a default value.ToDaysmethod to convert a float value to a TimeSpan representing days.ToHoursmethod to convert a float value to a TimeSpan representing hours.ToMinutesmethod to convert a float value to a TimeSpan representing minutes.ToSecondsmethod to convert a float value to a TimeSpan representing seconds.ToMillisecondsmethod to convert a float value to a TimeSpan representing milliseconds.
HashSetExtensions
AddRangeextension method to add a range of elements to the end of the HashSet.
ICollectionExtensions
IsNullOrEmptyextension methods to check if a collection is null or empty.IsEmptyextension methods to check if a collection is empty.AddUniqueextension method to add a unique item to the collection. If the item already exists, it will not be added.AddRangeUniqueextension method to add a range of unique items to the collection. If an item already exists, it will not be added.
IDictionaryExtensions
IsNullOrEmptyextension methods to check if a dictionary is null or empty.IsEmptyextension methods to check if a dictionary is empty.Addextension methods to add items to the dictionary, with options to replace existing items.AddRangeextension methods to add a range of items to the dictionary, with options to replace existing items.Mergeextension method to merge multiple dictionaries into one.GetValueandGetOrAddextension methods to retrieve values from the dictionary, with options to provide default values.RemoveValueextension methods to remove items from the dictionary based on their values.
IEnumerableExtensions
IsNullOrEmpty,IsEmpty, andIsNotEmptyextension methods to check if an IEnumerable is null, empty, or not empty.Hasextension method to find the first element that matches the conditions defined by the specified predicate.Findextension method to search for the first element that matches the conditions defined by the specified predicate.FindAllextension method to retrieve all elements that match the conditions defined by the specified predicate.Exceptextension method to produce the set difference of two sequences.Withoutextension method to filter elements based on a predicate that identifies the ite...