Tagger
Table of Contents
Some useful information and limitations. 4
Enable order tags alphabetically. 7
Order attached tags alphabetically. 7
Order the tags alphabetically in groups. 7
Order the groups alphabetically. 7
Step 2 – Setup search logic 14
Thank you for the purchase of Tagger.
Probably, you have found Tagger, because you have the same problem as me.
You want more than just one tag on a GameObject. Besides, you want to search for GameObject with specific tags. Moreover, you want the search being performant. Now, here comes the Solution: Tagger.
Multi-Tagging, Group of Tags, Fast, Easy to use, Efficiency.
GameObject has its Monobehavior attached aka TaggerScript.
The Script holds only one thing: The Identification Number of your attached tags to this GameObject.
In your Projects lays a ScriptableObject aka TaggerData.
The TaggerData store the logical connections (also which ID has which tags).
You can not use the same tag name in different groups. Groups are only a help for you to organize your tags. Technically, groups don’t affect the Tagger-System. You can search with groups, but you can not have like “Size.A” and “Level.A” because both tags are not “Size.A” and “Level.A”, they are “A” and “A”.
To open the context menu, click right on a tag or group. In the context menu, it is possible to move the tag in another group, change the color of the tag or delete it, as well to rename tags and groups.
You can change the color of a tag in the context menu or by script.
You can move a tag to another group. This can be done by script or in the context menu.
If you remove a group, you can choose between deleting its tags or move the tags to ungrouped. This can be done by script or in the context menu.
All Prefabs and Scene objects lose this tag. Moreover, even you add this tag later, it will not return. This can be done by script or in the context menu.
There is not much to say. At least that is what I hope. If you have any questions, please do not hesitate to contact me! However, here are a few small tips that may not be directly apparent.
In the preferences window in Unity, you find the “Tagger” tab.
This setting shows you the tags bar in the GameObject inspector. Note: If other assets use a customs inspector for GameObjects, this might be overridden or override other assets inspectors. (The Tag GameObject Inspector is currently unavailable due to a bug The normal Component Inspector of Tagger Script must be used. )
Always show the tagger menu, even there is no tagger script assigned. It does this automatically if you add a tag over the add menu.
This setting shows the group prefix in tags on GameObjects. Like: Group.Tag
This setting enables the ordering of tags and groups. Customizable with the following settings. This setting only affects visual and does not change the data order in the lists and arrays.
This setting orders the tags that are attached to the GameObjects alphabetically.
Ignore groups when ordering the tags on GameObjects.
As the title says, order the tags alphabetically in groups.
As the title says, order groups alphabetically.
First of all, read this note:
DO NOT USE METHOD / FIELDS WITH INTERNAL PREFIX!
IT COULD BREAK THE TAGGERSYSTEM.
It is that easy.
Second, the source code has been thoroughly documented. If something is not understandable, please get in touch with me.
You can access the Tagger over the static class TaggerSystem.
Here you find all functions of the Tagger. For data specific method access the current TaggerData over the TaggerSystem.Data property.
The TaggerSystem class is used to search and manage tags of GameObjects.
The TaggerData class is used to store all tag information. Tags, Groups, Color, IDs.
You possibly can have multiple TaggerData. However, it is not recommended because of the IDs. If you use the wrong TaggerData to identify prefabs they are created with another TaggerData, it is possible to mess up the IDs of the instanced prefabs and you probably will not find it with the search because their IDs pointed to other tags as you expected.
The ITaggerDataLoader interface is used to create a custom Tagger data loader. The TaggerDataLoaderDefault cannot be used to save at runtime. It only loads the in-editor time created TaggerData. If you want to use your own custom Tagger data loader, just implement the interface ITaggerDataLoader to your class and set the property TaggerSystem.DataLoader. Don’t forget to do this in editor time too. So make sure that your runtime save & load system is compatible with the editor time changes.
The link helps you to run code in editor time.
https://docs.unity3d.com/Manual/RunningEditorCodeOnLaunch.html
Over the following methods found in the static class TaggerSystem….
GameObject FindGameObjectWithTag(string tag)
HashSet<GameObject> FindGameObjectsWithTag(string tag)
HashSet<GameObject> FindGameObjectsWithTags(TaggerSearchMode mode, params string[] tag)
…it’s possible to search for tagged GameObjects in a simple way.
Example tags used in follow scenarios: Blue, Big, Cube
The mode and means, the searched GameObjects needs every specified tag.
Returns only GameObjects which have the tags Blue AND Big AND Cube.
The mode or means, the searched GameObjects must have at least one of the specified tags.
Returns only GameObjects which have the tags Blue OR Big OR Cube OR combination of these tags.
The mode not means, the searched GameObjects may not have the specified tags.
Returns Only GameObjects which have NOT the tags Blue OR Big OR Cube OR combination of these tags.
The following method is the easy one of the complex searches.
You enter a pattern, and this method creates for you the TaggerAdvancedSearch.
You must follow a couple of rules:
Valid Pattern:
TAG OPERATOR TAG
TAG, TAG OPERATOR TAG OPERATOR TAG
Now with infill…
Red & Blue | Cube
You also can use brackets for clarity, but the logic ignores the brackets.
(Red & (Blue | Cube))
I am strongly recommended to view the example file: Plugins\HeiKyu\Tagger\Examples\AdvancedSearchExample.cs
The following is just an additional explanation for the example file.
With the class TaggerAdvancedSearch, you can do complex searches. However, there is a current existing limitation. Every TaggerAdvancedSearch can only have one child search. Through this, you can only create a nested search instead of multiple logic.
For clearance, an example:
As a programmer, you write in logic
A & B & C … or … A | B & C … or … A & (B | C ) & D
The last one is not directly possible. Because A cannot have AND (B | C) AND D. You must reorder the logic to A & D & (B | C). If you have trouble to understand this, follow the simple rule:
Every logic has its brackets!
(A & (D & (B | C)))
For the other examples:
(A & (B & C))
(A | (B & C))
I hope this makes this a little bit better to understand this currently existing limitation.
You can either start with one created class for every command like this:
TaggerAdvancedSearch red = new TaggerAdvancedSearch();
TaggerAdvancedSearch small = new TaggerAdvancedSearch();
TaggerAdvancedSearch large = new TaggerAdvancedSearch();
TaggerAdvancedSearch blue = new TaggerAdvancedSearch();
red.SetTags("Red");
small.SetTags("Small");
large.SetTags("Large");
blue.SetTags("Blue");
Or you can start with only one class and work with these. On the first class you set the first tag.
TaggerAdvancedSearch search = new TaggerAdvancedSearch();
search.SetTags("Red");
In the constructor of the TaggerAdvancedSearch you can set if the first tag as include (also and) or excluded (also not) work.
You can choose between different ways to build up your logic.
(red & (small | large & blue));
red.And(small.Or(large.And(blue)));
Or when you choose to work with only one class…
search.And("Small").Or("Large").And("Blue");
If you want, then call void Research();
This complete internal processing. The method is automatically called if it needed by the Tagger itself.
If you change the search or create/delete/move tags or groups the search, it becomes dirty, and it calls this method self.
The only reason why this method is public is, you can save a couple of milliseconds before the actual search started.
Now you have built up a search that can search as many you need.
Now you can call the method HashSet<GameObject> MatchedGameObjects(). This will search for the GameObjects returns them.
The search is designed to be as fast as possible. “Just” a dictionary access and list accumulation.
Every time you call this method, it returns the current registered tagger GameObjects by the TaggerManager.
TaggerFilter makes it possible to define a set of tags via the inspector (or via C# API) and then to query via a method whether a GameObject matches this set of tags.
Decorate any serialized field with this attribute to make a list of tags that can be edited from the inspector. This TagId can then be used further with the TaggerSystem.
If there is a need for a community, it will be added in the future. Currently not planned but in mind.
Online Documentation - always new - Version 1.7