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