Search Unity

Tag Frenzy - Multiple Tags per Game Object in Unity

Discussion in 'Assets and Asset Store' started by NeilMeredith, Nov 23, 2013.

  1. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    $TagFrenzyForum.jpg

    Now Available! https://www.assetstore.unity3d.com/#/content/13170

    Tired of only being allowed one tag per game object in Unity? Me too...that's why I created Tag Frenzy.

    Features
    • Unlimited tags per object
    • Auto import existing tags to Tag Frenzy (one click import)
    • Tag enumeration class auto generated - get strongly typed tags
    • Extension methods to GameObject to get all tags as a list of string or a list of enums
    • Custom editor window to add/edit/delete tags

    Check it out below, and let me know if you would be interested in this! I'll try to get a free version together sometime in the near future.


     
    Last edited: Dec 3, 2013
    TheDudeFromCI likes this.
  2. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    Definitely interested in this. Looks really good.
     
  3. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    Thanks, I'll let you know when it is out! I submitted it yesterday and it normally takes about a week to get approved, but with the holiday coming up it may take a bit longer.
     
  4. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    +1 Will watch this thread for news. Good luck with it Neil!
     
  5. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
  6. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    How performant is this compared to Unity's tag system?
     
  7. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    Although I haven't directly tested it against Unity's tag system, performance should be pretty good.

    The way I can have multiple tags is by adding an extra component to all game objects to let me know which of the tags have been selected for each game object.

    The code them makes a call to the built in Unity GameObject.FindObjectsOfType to get all of the tagged components, then loops through them to figure out which are selected and which are not.

    So I would say cache the result of the call if possible (same as you would do for any GameObject.FindObjectsOfType call) and it will be plenty fast. You could call it continuously in an update loop, but it might be a little slow in that case.

    Also, I am currently running a giveaway here (http://forum.unity3d.com/threads/217869-Tag-Frenzy-giveaway-10-free-copies, and there are two free copies of my asset left. Do you want one of them to try it out yourself?
     
  8. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    Updated on the asset store with support for saving/editing tags on a Mac (thanks to Cristian for finding this issue), as well as two new tag match options.

    The two options are "Not", which will match any tags except for the one you pass into the method call, and "Exact", which will only return matching objects with the exact tags as you pass in (no more or less are allowed).
     
  9. aliozan

    aliozan

    Joined:
    Nov 18, 2013
    Posts:
    9
    Awesome asset. I need this. Can you send me a copy. it is appearing free on asset store but i cant download it.
     
  10. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    Sure, PM me your email address and I'll send it to you. It currently requires Unity 4.3 since it is using the System.Xml.Linq library. I plan to rewrite the save at some point so this can be used in earlier versions of Unity, I just haven't gotten around to it yet.
     
  11. bitbutter

    bitbutter

    Joined:
    Jul 19, 2012
    Posts:
    60
    How would one go about adding a tagfrenzy tag to an object in code? (unityscript)
     
  12. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    I'm not sure in unityscript, I've only worked with c#. You can use the AddTag extension method (add using GameObjectExtensions) to the top of your script, and then call YourGameObjectName.AddTag("TagName").

    This is an internal method though (used my the tag editor window), and will only work with existing tags. I'm not 100% sure this will work in your specific case since I have only tested it with the tag editor window, but give it a shot and let me know if it works for you.
     
  13. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Unfortunately Tag Frenzy doesn't work with Web Player on 4.3.2f1 Pro

    Assets/TagFrenzy/Scripts/Core/MultiTagManager.cs(7,18): error CS0234: The type or namespace name `Linq' does not exist in the namespace `System.Xml'. Are you missing an assembly reference?

    I moved system.xml.linq.dll from /Assets/Editor to /Assets/Plugins which resolves this error, however it then falls over again:

    Assets/TagFrenzy/Scripts/Core/MultiTagManager.cs(216,22): error CS0117: `System.IO.File' does not contain a definition for `WriteAllLines'

    As this is by design for security and therefore won't have a workaround, do you have any plans to support webplayer in the future?
     
  14. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    Hmm... I didn't realized the webplayer had this limitation, but I supposed it makes sense that it does. I didn't have any immediate plans to support the webplayer, but may be able to work around this by saving the tag data in the PlayerPrefs, which are accessible from the WebPlayer. It is a little inconvenient in the sense you can't just copy the tags to a new project by moving a file like you can when it is saved to an xml file, but it should work around the problem.

    I'll look into this some more.
     
  15. halfbot

    halfbot

    Joined:
    Sep 22, 2013
    Posts:
    19
    Neil, I love this asset. Very useful and becoming one of my favorite goto helpers. There is a problem I have noticed over the last few week of using it. If you writhe any code depending on on the Tag enum itself it becomes unreliable if you add any new tags in. This is because any new tags are added in alphabetic naming order rather than the order you added them in.

    So for instance if I create a list based on the tags like

    public List<Tags> interactsWithTags;

    and my tag list look like:

    Apples
    Balls
    Player
    Z

    then later after adding object to that list I added in a new tag 'ANewTag'

    my list now looks like

    ANewTag
    Apples
    Balls
    Player
    Z

    this is a problem because any list which had Apple in there now points to ANewTag, likewise Balls->Apples,Player->balls etc

    I know this is a side effect of building up the enum but perhaps it would be better to add in the enum AND the unique ID. So the enum would still be sorted but pointing to a constant ID that doesn't change with every addition.

    ANewTag = 4
    Apples = 0
    Balls = 1
    Player = 2
    Z = 3

    what do you think?

    If you do decide to do this the changes are simple but I can save you the trouble simply do this:

    In MultiTagsWindow.cs in function Update add :

    Code (csharp):
    1.  
    2. public static void Update(List<EditorTag> newTags)
    3. {
    4. //code removed
    5. ...
    6. // code removed
    7.  
    8. else
    9. {
    10.   xdoc.Element("tags").Add(
    11.   new XElement("tag",
    12.   new XAttribute("id", id.ToString()),
    13.   edTag.Tag)
    14.   );
    15.  
    16.   edTag.Id = id.ToString(); // <----- add this to force the update before save, otherwise it will be 0
    17.   id += 1;
    18. }
    19. //code removed
    20. ...
    21. // code removed
    22. }
    23.  
    And modify the two Add lines in CreateTagClass in MultiTagManager to:

    Code (csharp):
    1.  
    2. contents.Add(cleanedTag + "=" + newTags[i].Id  +  ",");
    3.  
    and

    Code (csharp):
    1.  
    2. contents.Add(cleanedTag + "=" + newTags[i].Id);
    3.  
     
    Last edited: Mar 11, 2014
  16. NeilMeredith

    NeilMeredith

    Joined:
    Jul 15, 2013
    Posts:
    81
    Thanks, this is a good idea. I'll make this update in a future release, I'm glad you are finding the asset useful!
     
  17. Member123456

    Member123456

    Joined:
    Oct 17, 2012
    Posts:
    237
    Good Day! First I would like to say I enjoy using this little gem but there are a few things I would like to have fixed.

    1. Can you make your plugin look for the folders it needs in folders that are nested under Assets. I like to move all my 3rd party tools into an Extensions folder to keep the assets root clean. I fixed this for myself as of now, just think its a good idea to make it generic so people can declutter the assets root.

    2. The previous post from halfbot about Enum dependencies. Is the fix almost official?
     
  18. Bubagent86

    Bubagent86

    Joined:
    Jan 3, 2014
    Posts:
    13
    Hey ZionMoose, could you tell me how you changed where the plugin looks for it's folders? I'm using boo, so I have to put this in standard assets to access it, but can't seem to figure it out.

    Thanks!
     
  19. webik150

    webik150

    Joined:
    Mar 23, 2013
    Posts:
    62
    Hey! It looks like I probably won't get an answer, but how can I set tags through code?

    EDIT: Oh! I'm blind.... It's just AddTag
     
  20. csullivan

    csullivan

    Joined:
    Jul 22, 2015
    Posts:
    1
    How do I remove TagFrenzy from my project? I've tried deleting the TagFrenzy folder, but every time Unity compiles scripts, something re-imports the folder and I have to delete it again.
     
  21. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @NeilMeredith ,

    If this is based upon only integer enumeration bitwise isn't it limited to only 32 tags?
     
  22. TheDudeFromCI

    TheDudeFromCI

    Joined:
    Oct 21, 2014
    Posts:
    15
    This is a really good asset, and has really helped me develop my games. Thank you very much. ^^
    It's very useful.
     
  23. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @NeilMeredith , and @TheDudeFromCI ,

    Thanks but are all GOs limited to 32 tags or truly unlimited? Also, can this work with prefabs? How would it work with prefabs? Can you search for a GO or Prefab or List of GOs or List of Prefabts by reference to more than one Tag?
     
    Last edited: Aug 9, 2016
  24. chickensaver

    chickensaver

    Joined:
    Oct 8, 2016
    Posts:
    2
    This may seem like an elementary question, but how would you write else if (collision.gameObject.tag == "Criminal")
    with these types of tags? The method shown above doesn't seem to work.
     
  25. chickensaver

    chickensaver

    Joined:
    Oct 8, 2016
    Posts:
    2
    This is in javascript (unityscript) BTW.