Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- public static class GameObjectTools
- {
- // usage: GameObjectTools.FindObjectsInTagGroup("ParentGroup");
- // will return all in ParentGroup/ChildGroup1 ParentGroup/ChildGroup2 etc...
- public static GameObject[] FindObjectsInTagGroup(string group)
- {
- string[] tags = UnityEditorInternal.InternalEditorUtility.tags;
- var objs = new List<GameObject>();
- for(int n=0; n<tags.Length; ++n)
- {
- if (tags[n].StartsWith(group+"/"))
- {
- objs.AddRange( GameObject.FindGameObjectsWithTag(tags[n]));
- }
- }
- return objs.ToArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment