Tag mask dropdown like Layer mask

Is it possible to create a tag mask dropdown similar to the layer mask dropdown in a custom inspector, to be able to select multiple Tags?

EDIT:
the tags are not known in advance.

1 Answer

1

Sure. Just use the EnumMaskField, with a custom enum of your choice.

Make sure the enum uses correct values for the bitmask:

Example:

private enum MyEnum
{
    MyValue1 = 2,
    MyValue2 = 4,
    MyValue3 = 8,
    MyValue4 = 16,
    MyValue5 = 32,
}

Thank you GameVortex, but how can I create the Enum dynamically if I don't know the Tags in advance? PS: I've updated my question to specify this.

Then you can use the [MaskField][1] instead and edit the string array to contain the Tags you want. [1]: http://docs.unity3d.com/ScriptReference/EditorGUILayout.MaskField.html

Thanks! That's what I was looking for! PS: although undocumented, UnityEditorInternal.InternalEditorUtility.tags handy returns a string array with all Tags

If you update your answer with MaskField suggestion, I'll be glad to mark it as the right one!

@GameVortex can you show how to do it. I mean update the answer and show all the process. I am really new and I want to learn how to do it but the only reference is this post and I really very new for understand your answer. Please if you can provide an answer with all the code required for create a TagMask I will appreciate a lot. PS: the link about EnumMaskField doesn't show the code in c# :(