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(this GameObject go) where T : Component { if (go == null) { return null; } T val = go.GetComponent(); if ((Object)val == (Object)null) { val = go.AddComponent(); } return val; } }