using System.Collections; using System.Collections.Generic; using UnityEngine; public static class UnityExtends { public static T GetOrAddComponent<T>(this GameObject go) where T : MonoBehaviour { T component = go.GetComponent<T>(); if (component == null) component = go.AddComponent<T>(); return component; } }