I know this is a long shot but is there a way to get the element number of a tag? that would be nice.
I guess you mean the index of a tag inside the tagmanager? If that's what you're after: NO. The tag array that you see inside the tagmanager is not really available at runtime.
You could create an own array with the tagvalues you’re after. If you use a generic List (C#) or List (JS) you will have the function IndexOf that will return the index of a given tag.
Another way would be to create an enum with the tags and use Enum.Parse() to convert a string into the enum value.
If you mean the GameObject ID number from a tag, I don't see why it would be possible to do so. Tags are not unique, and many GameObjects can share one tag. Further, a tag is nothing more than a string.
You could get the numbers of EVERY object that has a particular tag by adding every GameObject with that tag to an IList (or something equivalent), and then figure out what you want to do with those objects. But tags are not unique identifiers for GameObjects, and weren't made to be used that way. Rather, they're supposed to be a form of categorizing multiple GameObjects and saying "Hey, all these objects are similar".
If you tell us what exactly you're trying to do, I'm sure someone can figure out a better way to accomplish it.
I know it’s a really (really) old thread, but I found it, so maybe others will too.
There is an optional work around that I use. It won’t work for everyone but may help some out of a hole.
As a Tag is just a string, you can use that string to represent the index, so you could have a tag “1”, or “42” and so on. You can then parse the string to get the int. To avoid conflict with other tags that do not follow the ‘integer format’ you can precede it with a unique (within your list) character such as a hash. Check the prefix with ‘tag[0]’. You can even have a number of prefixes, and this allows you to create pseudo arrays of tags, such as “A1” and “B1” for example. Here you would use tag[0] to get the first character and tag.Substring(1) to get the remaining digits.
It’s a pretty flexible approach, if a little harder to read…
Might help someone?
Danny