All The Tags! - Unity3D Tags Replacement (Multiple tags, better performance, etc!)

All The Tags!
Asset Store ($10) | Documentation

All The Tags! Replaces the built in tagging system in Unity3D. It’s sole purpose is to allow you to add more than one tag to any object, however there other benefits too! It performs substantially better than doing a standard string compare, generates no garbage and allows you to customize your tags with colours to stay organized!

Screenshots


FAQ

The documentation mentions that the AllTheTags methods never return null? What do they return if it doesn’t find any objects?
Click for answer

It just returns an empty collection of objects. This way you don’t have to do null checks everywhere.

var taggedObjects = Tags.FindGameObjectsWithTag("MyTag");

foreach(var taggedObject in taggedObjects)
...

Instead of

var taggedObjects= Tags.FindGameObjectsWithTag("MyTag");

if(taggedObjects!= null)
{

foreach(var taggedObject in taggedObjects)
...

Do I need to ensure every GameObject has an AllTheTags component before I pass them along to an AllTheTags function?
Click for answer

No - AllTheTags is very rebust - if an object does not have an AllTheTags component, it will add it for you when you try to check that GameObjects tags. It won’t throw any errors at you.

So you could safetly do Tags.HasTag/etc on any object in your project. Whether they have an AllTheTags component or not doesn’t matter!

Simply add the ‘AllTheTags’ component to any object that needs one via the inspector, and the rest will handle itself :slight_smile:

If an object does not have an AllTheTags component, it is considered to have ‘no tags’.

Tags.FindGameObjectsWithTag(string tag) - how exactly do I use it?
Click for answer

By default, the FindGameObjectsWithTag returns a ReadOnlyCollection of objects. This is just like a List except that you can’t add objects to the list or remove objects from it! The reason it is done this way is because most of the time all you want to do with the result of FindGameObjectsWithTag is iterate over all of the objects and run some code on each object. A ReadOnlyCollection is fine for this task, and it means that we don’t have to allocate a new List of objects in memory to hold the result of every FindGameObjectsWithTag operation. Nice and efficient. :slight_smile:

You can iterate over a ReadOnlyCollection with a foreach statement, exactly the same as List.

If ReadOnlyCollection doesn’t fit your requirements however, you can still get a normal List out of the results fairly easily so you can do whatever you like with the results!

List<GameObject> myList = new List<GameObject>( Tags.FindGameObjectsWithTag("MyTag") );
1 Like

Coming very soon is an update to quickly fetch all of the objects in the scene with a certain tag. Works much faster than the built in solution to Unity! I will release some figures soon :slight_smile:

For now though… Unity vs AllTheTags! when checking to see if an object has a certain tag.

I checked to see if a GameObject was tagged as ‘MainCamera’ 2 million times. The GameObject was tagged as MainCamera using the Unity tag system, and it was tagged as MainCamera and 3 other tags as well using All The Tags.

Unity3D took 568~ ms to perform this operation and generated 72.5 MB of garbage (GC Alloc).
All The Tags! took 412~ ms to perform this operation and generated no garbage.

As you can see the checks are very quick and very clean. You can have lots of tags on every object in your game and you can check the game objects tags instead of its components to try and figure out what type of object you are dealing with!

If your ‘bullet’ hits the a GameObject, how do you know if your bullet should deal damage to the object? You could do a GetComponent on that GameObject and check to see if it has a ‘Damagable’ component, or you can just check its tag to see if you should apply some damage to that object and only do a GetComponent when needed.

Hey look! Vouchers :slight_smile:

If you like it, don’t forget to rate us and leave a comment here! Enjoy!

- All Taken -

I got the middle one (ASV-77MU-NLAJ-XJPX-JWRF-RC6Y). Thanks!

I have your “Better Trails” is the reason this asset caught my eye. If I like it I’ll buy one of your other assets (could use the NavMesh 2D) because it feels weird getting something for free.

Don’t feel weird! You can always ‘pay us back’ by letting us know what you think! We’d love some feed back and we’d love to hear what type of features you all would like to see - that’s why we are giving away a few copies! :slight_smile: Right now AllTheTags! is in its infancy, but we’ve got a strong foundation to build up on!

As mentioned before, I am about to submit an update for AllTheTags. We’re adding a function to fetch all the GO’s in the scene with a particular tag and it is very quick compared to Unity’s built in function (FindGameObjectsWithTag)! Thinking about adding some other helper methods too, like a 'FindGameObjectsWithTagAroundPoint’.

Was too late for the Vouchers. Will get it soon.

Uh, this could come in handy. But is it compatible with Unity 4.3.X ?

I imagine it would work fine, but I’ll download version 4.3 and find out myself. Will let you all know in a few hours (I am not home right now!).

If it works fine I’ll make sure I submit the next update under 4.3 :slight_smile:

1 Like

@BTStone_1 I am making use of [DisallowMultipleComponent] which is 4.5.X and up.

I think I can get rid of it and just do some checks to prevent multiple copies of the AllTheTags component on one GO. Should be able to make it work fine with 4.3 in the next update

If you end up buying it before the update hits the store, just remove that attribute from AllTheTags.cs and it will all work fine. Just avoid adding the component more than once to a GO! :slight_smile:

Great, as soon as the update hits the store I’m on it!

And +1 to Helper-Functions! :smile:

Ok, Submitting an update for the asset store team to review now! This update introduces the FindGameObjectsWithTag method. Substantially faster than Unity’s built in method. AllTheTags! will internally keep a record of all GameObjects and associated tags that exist within your scene. Makes it really easy and quick to find objects with tags. Here are some figures.

100 GameObjects.
‘Test’ tag applied to all GO’s (Both Unity and AllTheTags!)
1,000,000 iterations - we invoke FindGameObjectsWithTag (Both Unity and AllTheTags!) a million times.

Unity3D took 2500~ ms to perform this operation and generated 405~ MB of garbage (GC Alloc).
950~ ms was spent on GC.Collect, 1550~ ms was spent on the actual operation

All The Tags! took 215~ ms to perform this operation and generated 12~ MB of garbage (GC Alloc).
30~ ms was spent on GC.Collect, 185~ ms was spent on the actual operation

I am really excited about this update. The method really helps showcase the power :slight_smile:

2 Likes

Awesome news! 1.1.0 is live! More features soon, get it while it’s hot :wink:

I’ve scrapped the GameObject extension methods as it was getting a little confusing…! GameObject already has some ‘tag’ methods, adding mine in there was a little bit too much. So now you can find all the AllTheTags! methods under the ‘Tags’ static class (ie: Tags.HasTag(gameObject,"tag"))

Change log 1.1.0

  • New ‘Tags’ static class, will hold all AllTheTags! methods (Like HasTag, etc)
  • Extension methods are now obsolete (Use the Tags static class)
  • 2 new methods - FindGameObjectsWithTag and FindGameObjectsWithTagAroundPoint
  • Now works with Unity 4.3.X onwards
2 Likes

Woo! We’ve reached 3 reviews now which means we finally have a star rating. Thanks everyone!

Soon I’ll be releasing another update to help you find tagged objects that are childed to a specific object (FindChildrenWithTag).

Release soon and release often I guess. :slight_smile: Your tags will be preserved in between updates - to update AllTheTags! In your project, all you need to do is import the newest asset from the asset store.

1 Like

Thanks for the update. I am getting an error - "The namespace ‘global::’ already contains a definition for ‘Tags.’

It’s the only error in the console, but not sure if there is a way to check what other asset might have that same namespace? I want to keep All The Tags installed and get rid of any asset that is conflicting.

Hey @MIK3K
I am not sure what package it could be conflicting with. You need to open up your MonoDevelop and search your entire project for “class Tags”. It should reveal to you the files that define a class called Tags.

I think I will move Tags class in to its own namespace in the next release to avoid any conflicts (“Tags” is a pretty common word…!).

My apologies :slight_smile:

Let me know if you get it working!

Adding this to buy list, this is so amazing o.o

I just learned something new - how to search these things in MonoDevelop (I’m not a programmer . . . or anything computer related really haha - hobby for me). Found the other asset which a little RPG system to learn from. I already had it in another project and don’t need it here.

Thanks for your time and teaching me something today!

@MIK3K

No problem! Glad you worked it all out :slight_smile: Don’t forget to drop us a review on the store once you are done evaluating it!

@Gekigengar

Thanks for the kind words man! When you get around to purchasing it, We’ll be here for feature requests/suggestions/troubleshooting so feel free to get in touch with us. :slight_smile:

+1 for own namespace :stuck_out_tongue:

Haha :slight_smile: I have everything internal namespaced already, I left the Tags static class in the global name space so it was less of a hassle to use, but I think it is decided now - definitely giving it its own namespace in the next update!