using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class GameObjectExtension
{
    public static T GetOrAddComponent<T>(this Component gameObject) where T : Component
    {
        var trigger = gameObject.GetComponent<T>();

        if (!trigger)
        {
            trigger = gameObject.gameObject.AddComponent<T>();
        }

        return trigger;
    }
    public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
    {
        var trigger = gameObject.GetComponent<T>();

        if (!trigger)
        {
            trigger = gameObject.AddComponent<T>();
        }

        return trigger;
    }
}