using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; namespace BITKit { public static partial class Extensions { public static bool TryGetRoot(this Component self, out Root root) { root = null; try { if (self is not null && self.TryGetComponent(out root)) { root = root.root; return true; } } catch (System.Exception) { return false; } return false; } } public class Root : MonoBehaviour { [Header(Constant.Header.Settings)] public Root root; public string id; [Header(Constant.Header.Gameobjects)] public Dictionary childs = new(); public Root Get(string id) { if (id.IsNullOrEmpty()) { return this; } else { return childs[id]; } } } }