Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by reptilebeats · Aug 05, 2012 at 11:36 PM · editoreditorwindowtagshierarchy

Find Objects with particular tag

Hi there I cant find it or it doesnt exist, i would like to see all objects in the hierachy only containing a certain tag, is this possible??

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image reptilebeats · Aug 05, 2012 at 11:37 PM 0
Share

i notice there is a way to see only labels in the project pane but i cant seem to find where and if the tag view is

avatar image Seth-Bergman · Aug 06, 2012 at 07:08 AM 0
Share

you would probably want to create a custom editor component I guess.. if it were me, I might consider switching to na$$anonymous$$g conventions as opposed to tags, then everything will all group up automatically by alphabetization (just a suggestion)

2 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by flamy · Aug 06, 2012 at 12:40 PM

well i cannot find a way to show only particular objects in hierarchy but i found a way to see the list of objects in a custom window and select the objects using that window in the hierarchy.

 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 
 public class TagSearcher : EditorWindow {
  
  static TagSearcher window;
  static string tagValue="";
  static string oldTagValue;
  static Vector2 scrollValue=Vector2.zero;
  static GameObject[] searchResult;
  
  [MenuItem("EditorUtility/TagSearcher")]
  static void OpenTagSearcher()
  {
         
  
      window = (TagSearcher)EditorWindow.GetWindow (typeof (TagSearcher));
      searchResult =  GameObject.FindGameObjectsWithTag(tagValue);
  
    
  }
  
  void OnGUI()
  {
  
  
     oldTagValue=tagValue;
  
     tagValue=EditorGUILayout.TagField(tagValue); 
  
  
     if(tagValue != oldTagValue)
     {
  
  
        searchResult = GameObject.FindGameObjectsWithTag(tagValue);
        Selection.objects = searchResult;
  
     }
  
     scrollValue=EditorGUILayout.BeginScrollView(scrollValue);
  
     if(searchResult != null)
     {
  
        foreach(GameObject obj in searchResult)
        { 
           if(obj !=null)
           {
              if(GUILayout.Button(obj.name))//,GUIStyle.none))
              {
                  Selection.activeObject =  obj; 
                  EditorGUIUtility.PingObject(obj);
              } 
          }
          else
          {
              searchResult = GameObject.FindGameObjectsWithTag(tagValue);
              Selection.objects = searchResult;
              break;
          }
      }
  
   }
  
   EditorGUILayout.EndScrollView();
   } 
  
 }
 
     

By default it will select all objects with that tag. but you can select the individual objects also using the window.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image reptilebeats · Aug 06, 2012 at 03:41 PM 1
Share

nice saves me a lot of time learning and making something like this, to be fair i probably wouldnt of though as unity have improved on how you find stuff, so it might support it.

either way nice work, this is going to be used frequently by me, its nice to be able to check my tags when testing

avatar image sdgd · Mar 17, 2013 at 05:32 AM 1
Share

very good :)

thanks I've learned how could I do my own unity editor modifiers and at last I can see if I have some tags unused so I know what I can delete or rename

so I don't end doing 100 tags and only few usable easier to track all :)

thumbs up :)

heh thought I had some unused ones but now I see I have all used and even know by what :)

avatar image Meceka · Jul 16, 2014 at 09:24 PM 0
Share

This script doesn't work in unity 4.5.2 , it crashes unity. If anyone knows the reason, please modify the script.

avatar image Tryggvienator · Jun 21, 2015 at 11:14 PM 0
Share

Very nice! Saved me a lot of time hunting down tags. $$anonymous$$e like.

avatar image Skelly1983 · Feb 06, 2018 at 10:40 PM 0
Share

Saved a lot of time with this, thanks

avatar image
0

Answer by MaT227 · Aug 06, 2012 at 10:58 AM

You can see object by component just by adding :
t:mycomponent in the search field or you can do something like Seth said : http://docs.unity3d.com/Documentation/ScriptReference/Selection-objects.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gdp2 · Sep 27, 2017 at 06:30 PM 0
Share

Why the downvotes? This is actually a really helpful answer; that link has some good info and actually solves the problem posed by the OP.

avatar image Skelly1983 gdp2 · Feb 06, 2018 at 10:21 PM 1
Share

Because t: searches objects with components of the a certain type not a objects with the tag. Therefore it will not show for instance the "Player" tag.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

What is the best way to draw icons in Unity's Hierarchy window? 1 Answer

Having an issue with the hierarchy window 3 Answers

How to switch back the Hierarchy window to scene from prefab? 0 Answers

Is it possible to detect drag and drop in hierachy window? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges