blob: d1a66f48343ef4aba2974124f0e02670c49a3123 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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;
}
}
|