- Home /
How to search gameobject in scene by tag name
Seems like I have accidentally tagged an object in hierarchy as "Player" which is causing lot of issues. How do I locate it in hierarchy quickly instead of going through hundreds of objects and its children manually?
I can do it using code but I need to find it in the IDE but how? Please help
Answer by liortal · Apr 25, 2014 at 11:52 AM
You can combine the approach suggested by @fafase, and apply the selection to the objects found by that query.
Here's the full code for that (add this under an Editor folder):
using UnityEngine;
using System.Collections;
using UnityEditor;
public class SelectByTag : MonoBehaviour {
private static string SelectedTag = "Player";
[MenuItem("Helpers/Select By Tag")]
public static void SelectObjectsWithTag()
{
GameObject[] objects = GameObject.FindGameObjectsWithTag(SelectedTag);
Selection.objects = objects;
}
}
This will add a new menu item "`Helpers/Select By Tag`" to your toolbar. Clicking it will highlight should highlight all objects tagged with the given tag name (set by the static field "`SelectedTag`")
Answer by DiGiaCom-Tech · Nov 03, 2018 at 09:20 PM
@liortal ... Does anyone have an update for this? That would perhaps give a select list of all the tags saved in the project?
Your answer
![](https://koobas.hobune.stream/wayback/20220613143540im_/https://answers.unity.com/themes/thub/images/avi.jpg)