summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Utils')
-rw-r--r--WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs46
-rw-r--r--WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta11
2 files changed, 57 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs
new file mode 100644
index 0000000..84ce560
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs
@@ -0,0 +1,46 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public static class GameObjectExtensions
+{
+ public static void SetParent(this GameObject obj, Transform parent)
+ {
+ if (!(obj == null))
+ {
+ obj.transform.SetParent(parent);
+ }
+ }
+
+ public static GameObject Find(this GameObject obj, string name)
+ {
+ if (obj == null)
+ {
+ return null;
+ }
+
+ Transform transform = obj.transform.Find(name);
+ if (!(transform != null))
+ {
+ return null;
+ }
+
+ return transform.gameObject;
+ }
+
+ public static T GetOrAddComponent<T>(this GameObject go) where T : Component
+ {
+ if (go == null)
+ {
+ return null;
+ }
+
+ T val = go.GetComponent<T>();
+ if ((Object)val == (Object)null)
+ {
+ val = go.AddComponent<T>();
+ }
+
+ return val;
+ }
+} \ No newline at end of file
diff --git a/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta
new file mode 100644
index 0000000..2dd16b6
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Utils/GameObjectExtensions.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 460610b6a0fd5e14ba71f016385ca356
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: