Class GenericExtensionMethods
- Namespace
- CodeBase
- Assembly
- 4Experience.CodeBase.Core.Runtime.dll
A class that collects a variety of extension methods. Similar to: CustomExtensionMethods
public static class GenericExtensionMethods
- Inheritance
-
GenericExtensionMethods
Methods
ActivateGameObject(Component)
Active gameobject of that component - use optimized solution.
public static void ActivateGameObject(this Component component)
Parameters
componentComponent
ActivateGameObject(Component, bool)
Set active state for gameobject of that component - use optimized solution.
[Obsolete("Deprecated solution - use ActivateGameObject, DeactivateGameObject or SetGameObjectState instead - 25.10.2022")]
public static void ActivateGameObject(this Component component, bool state = true)
Parameters
componentComponentstatebool
BuiltinContains<T>(T[], T)
[Obsolete("Duplication of ContainsElement method - use ContainsElement instead - 25.10.2022")]
public static bool BuiltinContains<T>(this T[] collection, T value) where T : Object
Parameters
collectionT[]valueT
Returns
Type Parameters
T
ContainsElement<T>(T[], T)
Check if object array contains lookup object.
public static bool ContainsElement<T>(this T[] target, T lookupObject) where T : Object
Parameters
targetT[]lookupObjectT
Returns
Type Parameters
T
DeactivateGameObject(Component)
Deactivate gameobject of that component - use optimized solution.
public static void DeactivateGameObject(this Component component)
Parameters
componentComponent
DestroyClear<T>(List<T>, bool)
Destroy all gameobject related to components from list then clear list.
public static void DestroyClear<T>(this List<T> target, bool immediate = false) where T : Component
Parameters
Type Parameters
T
GetComponentInParentExcludeSelf<T>(Component)
Get component from parent (if any problem with component or parent doesn't exist it will return default of T).
public static T GetComponentInParentExcludeSelf<T>(this Component component) where T : Component
Parameters
componentComponent
Returns
- T
Type Parameters
T
GetComponentsInChildrenPath<T>(Component, ref List<T>, int)
Get components list (passing as ref) from target component and its children limiting the number of component occurrences (if component hasn't children or is null it will return empty array). Method use recurrence functionality.
public static void GetComponentsInChildrenPath<T>(this Component target, ref List<T> result, int inPathOccurences) where T : Component
Parameters
Type Parameters
T
GetComponentsInChildrenPath<T>(Component, int)
Get components array from target component and its children limiting the number of component occurrences (if component hasn't children or is null it will return empty array). Method use recurrence functionality.
public static T[] GetComponentsInChildrenPath<T>(this Component target, int inPathOccurences) where T : Component
Parameters
targetComponentinPathOccurencesint
Returns
- T[]
Type Parameters
T
IndexOf<T>(T[], T)
Get index of concrete component object from array (if there is no searched object it will return -1).
public static int IndexOf<T>(this T[] collection, T target) where T : Component
Parameters
collectionT[]targetT
Returns
Type Parameters
T
MoveTo(Rigidbody, Transform)
Set rigidbody position and rotation to target transform.
public static void MoveTo(this Rigidbody obj, Transform target)
Parameters
objRigidbodytargetTransform
SetDisableOptimized<T>(List<T>)
Disable target behaviour if behaviour is not disable.
public static void SetDisableOptimized<T>(this List<T> target) where T : Behaviour
Parameters
targetList<T>
Type Parameters
T
SetDisableOptimized<T>(T)
Disable behaviour state after making sure it is not null and is enabled
public static void SetDisableOptimized<T>(this T target) where T : Behaviour
Parameters
targetT
Type Parameters
T
SetEnableOptimized<T>(List<T>)
Enabled target behaviour if behaviour is not enabled.
public static void SetEnableOptimized<T>(this List<T> target) where T : Behaviour
Parameters
targetList<T>
Type Parameters
T
SetEnableOptimized<T>(T)
Enable behaviour state after making sure it is not null and is disabled
public static void SetEnableOptimized<T>(this T target) where T : Behaviour
Parameters
targetT
Type Parameters
T
SetGameObjectActiveAll<T>(List<T>, bool)
Change active state of all gameobject related to components from list - use optimized solution.
public static void SetGameObjectActiveAll<T>(this List<T> target, bool state) where T : Component
Parameters
Type Parameters
T
SetGameObjectState(Component, bool)
Set active state for gameobject of that component - use optimized solution.
public static void SetGameObjectState(this Component component, bool state)
Parameters
componentComponentstatebool
ToSprite(Texture2D)
Convert Texture2D to Sprite. Sprite will has x and y set to 0.0, width and height set the same as texture and pivot set to (0.5, 0.5).
public static Sprite ToSprite(this Texture2D texture)
Parameters
textureTexture2D
Returns
- Sprite