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