RoR2-ChensHelpers

Contains simple and useful helpers for RoR2 mod creators to use. Mainly caters to Chen's mods.

View on GitHub

ChensHelpers

Chen.Helpers.UnityHelpers

Extensions Class

Extensions for Unity objects.

public static class Extensions

Inheritance System.Object 🡒 Extensions

Methods  
DeepCopy<T>(T, GameObject) Creates a deep copy of a component and attaches it to the target Game Object.
DeepCopyComponentsFrom<T>(GameObject, GameObject) Creates a deep copy of components from the source towards another Game Object.
DeepCopyComponentsTo<T>(GameObject, GameObject) Creates a deep copy of components from the source towards the specified Game Object.
GetOrAddComponent<T>(Component) An extension that allows fetching or adding a component through the component of the GameObject.
If the GameObject has the component, it will only fetch it and return the component.
If the GameObject does not have the component, it will add one to it and return the component.
GetOrAddComponent<T>(Component, Action<T>) An extension that allows fetching or adding a component through the component of the GameObject.
This overload contains post-processing logic of the component.
Only used for cleaner code. Otherwise it is equivalent to assigning values after this method call.
GetOrAddComponent<T>(Component, Action<T>, Action<T>) An extension that allows fetching or adding a component through the component of the GameObject.
This overload contains post-processing logic of the component depending whether it was created or fetched.
Only used for advanced logic without having to do an if-else statement after the method call.
GetOrAddComponent<T>(GameObject) An extension that allows fetching or adding a component.
If the GameObject has the component, it will only fetch it and return the component.
If the GameObject does not have the component, it will add one to it and return the component.
GetOrAddComponent<T>(GameObject, Action<T>) An extension that allows fetching or adding a component.
This overload contains post-processing logic of the component.
Only used for cleaner code. Otherwise it is equivalent to assigning values after this method call.
GetOrAddComponent<T>(GameObject, Action<T>, Action<T>) An extension that allows fetching or adding a component.
This overload contains post-processing logic of the component depending whether it was created or fetched.
Only used for advanced logic without having to do an if-else statement after the method call.