# Unity3D Tag as a public variable in editor

How do you incorporate Tag strings into a scripts editor found in the inspector?

What it is I'm babbling about: When you create a public GameObject fooObject in a script, it shows up as a box that can have Game Objects dragged onto in its editor. It also has a small clickable dot that shows every Game Object that could be selected.

Now, say I have a public string fooString that would specifically be used for referencing the Tag strings of Game Objects (such as if (fooObject.tag == fooTag) or another use). Is there a way to define that string so that in the script's editor it strictly allows tag names to be used with it? I'm assuming with a similar clickable dot or a drop down menu of every selectable tag.

Although I could just manually type my string, a solution like the one above would have big object-orientated advantages. For example, if I was to change the name of this tag, it would change the string variable accordingly, as if the variable was a reference to such tag.

[Note to the moderators: I looked for an answer to this question for nearly 2 hours now to no avail. I understand that I may be missing some specific wrong word choice, in which case this question easily could have already been answered here. If this is closed as a duplicate, then, a quick comment explaining my mistake would be greatly appreciated.]

• Since you can change the tag at runtime, why worry about the editor? Just set an enum you can set in the editor and then set the tag approrpiately when your object enables. Would that work? – Plastic Sturgeon May 16 '15 at 0:56
• That would work, in fact its my current workaround. But ideally if I was to change the name of this tag, it would change the string variable accordingly, as if the variable was a reference to such tag. Question edited accordingly – James Hurley May 16 '15 at 1:06
• I understand better. Is there some other Type you could get instead of GameObject? For example if they are Ships, then public Ship fooShip. Then you could get the gameobject or components of that ship as needed from the reference. And it would only take objects of the appropriate type. – Plastic Sturgeon May 16 '15 at 1:30