Easy Tags 1.0
Improved Tag System for Unity
Loading...
Searching...
No Matches
Easy Tags Documentation

Easy Tags is an extension tool for the Unity tag system to let you better utilize tags in your game. Easy Tags has an extensive set of functionalities to help you better utilize tags in your game. The main functionalities of Easy Tags are as follows:

How To Use
Tag Manager Window

To open the Tag Manager window, go to Tools -> Easy Tags -> Tag Manager

Tag Manager Window Context Menu

It will open this window:

Tag Manager Window
Generate Accessible Tags

Easy Tags automatically generates and updates the accessible tags, but in case it doesn't, go to Tools -> Easy Tags -> Generate Accessible Tags:

Generate Accessible Tags Context Menu
      // Add the namespace
      using UnityEngine;
      using EasyTags;
      
      // Then you can use the Tags class to directly use the defined tags
      void Start() 
      {
          GameObject gameObject = GameObject.FindGameObjectWithTag(Tags.Player);
      }
      
Multiple Tags Component

To add Multiple Tags component to your game objects, either use the traditional method, or select your game objects and go to Tools -> Easy Tags -> Add Multiple Tags to Selected:

Add Multiple Tags to Selected

Multiple Tags Component:

Multiple Tags Component
  • Add multiple tags using the Tag Mask.
  • Click selected tags to remove them.
  • Open the Tag Manager.
[Tag] Attribute and TagMask Property

You can use the custom [Tag] attribute to use tag dropdowns and custom TagMask property to use masks for tags in your scripts:

      // Add the namespace
      using UnityEngine;
      using EasyTags;
      
      // Then you can use [Tag] attribute for tag dropdowns
      [Tag] public string tag;

      // And TagMask property for masks for tags
      public TagMask tagMask;
      

[Tag] attribute in inspector:

[Tag] attribute in inspector

TagMask property in inspector:

Generate Accessible Tags Context Menu
TagMask and MultipleTags Example Usages

TagMask and MultipleTags has some built-in functions that you can easily use. Here are some example usages of these functions:

      // Add the namespace
      using UnityEngine;
      using EasyTags;
      
      // Adding or removing tags from a mask
      public TagMask tagMask;

      void Start() 
      {
          tagMask = new TagMask (new string[] {Tags.Enemy, Tags.Player});
          tagMask.AddTagsToMask(new string[] {Tags.Knight, Tags.Archer});
          tagMask.RemoveTagFromMask(Tags.Player);
      }
      
      // Collision handling example using MultipleTags
      private void OnCollisionEnter (Collision collision)
      {
          // or use MatchesWith(tagMask) based on your use case
          if (collision.gameObject.GetComponent<MultipleTags>().HasTags(tagMask))
          {
              TakeDamage(10);
          }
      }
      
      // MultipleTags uses TagMask, so something like this is also possible
      string[] selectedTags = gameObject.GetComponent<MultipleTags>().TagMask.GetSelectedTags();

      // Although you can directly use MultipleTags for that
      string[] selectedTags = gameObject.GetComponent<MultipleTags>().GetSelectedTags();
      
TagMaskUtils Class

TagMaskUtils is a static utility class that has a lot of built-in function to use with MultipleTags and TagMask. Here is a summary of the things it can do:

  • Caches game objects with MultipleTags.
  • Uses the cache to efficiently serch for game objects using TagMask.
  • Compares game objects with TagMask.
  • Checks a list or an array for similarly tagged (MultipleTags) game objects using TagMask.
  • Uses the cache to efficiently search for transforms using TagMask
  • Does a traditional search for traditionally tagged objects (without MultipleTags attached) using TagMask
  • Modifies a TagMask using a tag or a list or array of tags.

Here are example usages for different types of functions in TagMaskUtils:

      // Add the namespace
      using UnityEngine;
      using EasyTags;
      
      // Prepare your TagMask either through code or in the inspector
      public TagMask tagMask;

      void Start()
      {
          // Find specifically tagged game objects that have MultipleTags attached
          GameObject[] archerEnemies = TagMaskUtils.FindGameObjectsWithTags(tagMask);

          // Find specifically tagged transforms that have MultipleTags attached
          Transform[] archerEnemiesTransforms = TagMaskUtils.FindAllWithTags(tagMask);
      }
      
      // You can even use TagMask to search for traditionally tagged game objects
      // This function finds game objects using more than one tag with TagMask
      // And it works for game objects that doesn't have MultipleTags
      GameObject[] allEnemies = TagMaskUtils.FindGameObjectsWithoutMultipleTags(tagMask); 
      
      // Collision handling example using TagMaskUtils
      private void OnCollisionEnter(Collision collision)
        {
            if (TagMaskUtils.CompareGameObjectsTag(this.gameObject, collision.gameObject))
            {
                // Do something if two MultipleTags game objects have any matching tags
            }
        }
        
      // You can also check if a list or array of GameObjects has similar MultipleTags
      public GameObject[] gameObjects;

      void Start()
      {
          if (TagMaskUtils.HasAllMatching(gameObjects))
          {
              // Do something if all of the GameObjects have the same tags in their MultipleTags
          }
      }