summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/Utils/GameObjectUtils.cs
blob: 416f097f5a64f5866be62b9584d26e75cc9c6b48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class GameObjectUtils
{

	public static T AddOrGetComponent<T>(this GameObject go) where T : MonoBehaviour
	{
		T comp = go.GetComponent<T>();
		if(comp == null)
		{
			comp = go.AddComponent<T>();
		}
		return comp;
	}

}