x


Is it possible to create a tag programmatically?

I'm setting a script to initialize common stuff I usually add to a new project, and one of those are some custom tags. Is it possible at all to create a tag programmatically?

more ▼

asked Nov 11 '10 at 07:06 AM

Rodrigo Moraes gravatar image

Rodrigo Moraes
95 3 4 12

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I don't think it's possible.. If you look it up in the Unity Script Reference you will find: "Tags must be declared in the tag manager before using them".

EDIT: You can actually assign tags to objects if you have already declared them in the tag manager. Example:

gameObject.tag = "Player";

This will work if you've made a tag called "Player" in the tag manager. The tag manager can be found by going to Edit -> Project Settings -> Tags

more ▼

answered Nov 11 '10 at 07:47 AM

Yoerick gravatar image

Yoerick
729 2 5 14

Ok, that's it then. A pity because I'm much more a code guy than a GUI guy. I wish I could do everything in code. Thank you.

Nov 11 '10 at 07:53 AM Rodrigo Moraes

Oh, I know about assigning existing tags. The question was about creating custom tags programmatically, though. I wanted to do this in a "setup project" kind of script.

Nov 11 '10 at 09:53 AM Rodrigo Moraes

Have you tried looking up the classes in the UnityEditor namespace? It's possible that you find something there.

Nov 29 '10 at 07:38 AM xeophin

As of Unity 3.1.0f4 there are no features in the scripting reference that I can find that would do this (create a layer/tag programatically). It would definitely be a handy tool to have.

Dec 10 '10 at 12:00 AM Steven Walker

I second this. I want to use about 560 different tags and I'm dreading the task of creating them manually.

Jan 21 '11 at 03:26 PM novo
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5072
x2085
x323

asked: Nov 11 '10 at 07:06 AM

Seen: 3108 times

Last Updated: Nov 11 '10 at 07:06 AM