Tanoda
ExtentionMethods.cs
Go to the documentation of this file.
2{
3 public static class ExtentionMethods
4 {
5 public static T GetOrAddComponent<T>(this GameObject child) where T : Component
6 {
7 T result = child.GetComponent<T>();
8 if (result == null)
9 {
10 result = child.AddComponent<T>();
11 }
12 return result;
13 }
14 }
15}
UnityEngine.Component Component
Credit Erdener Gonenc - @PixelEnvision.