ChensHelpers
Chen.Helpers.UnityHelpers.Extensions
Extensions.GetOrAddComponent<T>(Component, Action<T>) Method
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.
public static T GetOrAddComponent<T>(this Component component, System.Action<T> action)
where T : Component;
Type parameters
Parameters
component
UnityEngine.Component
The GameObject of the component to fetch from or add to
action
System.Action<T>
Post-Processor code
Returns
T
The component specified as T