summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Utils/UnityExtends.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Utils/UnityExtends.cs')
-rw-r--r--Assets/Scripts/Utils/UnityExtends.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/Assets/Scripts/Utils/UnityExtends.cs b/Assets/Scripts/Utils/UnityExtends.cs
new file mode 100644
index 00000000..d1a66f48
--- /dev/null
+++ b/Assets/Scripts/Utils/UnityExtends.cs
@@ -0,0 +1,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;
+ }
+
+
+}