15 lines
335 B
C#
15 lines
335 B
C#
|
using UnityEngine;
|
|||
|
|
|||
|
public static class ExtentionMethods
|
|||
|
{
|
|||
|
public static T GetOrAddComponent<T>(this GameObject child) where T : Component
|
|||
|
{
|
|||
|
T result = child.GetComponent<T>();
|
|||
|
if (result == null)
|
|||
|
{
|
|||
|
result = child.AddComponent<T>();
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|