3 public static class ExtentionMethods
5 public static T GetOrAddComponent<T>(
this GameObject child) where T :
Component
7 T result = child.GetComponent<T>();
10 result = child.AddComponent<T>();
UnityEngine.Component Component
Credit Erdener Gonenc - @PixelEnvision.