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