public static GameObject Find(string selector) { SelectorChain selectors = new SelectorChain(selector); FindVisitor visitor = new FindVisitor(selectors); SceneDescender descender = new SceneDescender(SceneManager.GetActiveScene()); descender.Descend(visitor); Transform result = visitor.GetTransform(); return(result != null ? result.gameObject : null); }
public static GameObject[] FindAll(string selector) { SelectorChain selectors = new SelectorChain(selector); FindAllVisitor visitor = new FindAllVisitor(selectors); SceneDescender descender = new SceneDescender(SceneManager.GetActiveScene()); descender.Descend(visitor); Transform[] results = visitor.GetTransforms(); GameObject[] output = GetGameObjectsFromTransforms(results); return(output); }