- Home /
Is it possible to create a new Tag by script ?
I'm writing an asset postprocessor that tags objects if their name contains one of an array of strings. Every time I create a new scene for this project, I have to add all the tags by hand. There's quite a number of tags and to keep the manual labor to a minimum (coders are lazy, right), I'd like to create the tags by script.
I'm not sure what you mean because when I make a new scene the tags are still there?
Oops, you're right, the tags are stored in the project, not the scene. Thanks for pointing that out !
Answer by Peter G · May 02, 2010 at 04:45 PM
It sounds like you would be better off creating a prefab for each object that you put into the scene, with scripts and other components included, then add a tag to that prefab. Then when you bring the object into, the scene, it will automatically have the tag.
That way all the objects are pre-tagged and any scripts you would have to put on them are already there. It can save you a lot of time.
Interesting thought, for the objects I want tagged this approach would certainly work. But, I have 20+ tags... I still would like to generate these by script.
I haven't seen a class that would allow you to implement that. I would search the editor classes for anything that mentions creating tags, and bring it back here. Otherwise you can do it manually and create prefabs to never have to do it again.
I already searched through the docs, all tag-related functions are for accessing and comparing them...
Well then, I'm sorry to say it, but it looks like you will have to do it manually.
Your answer
Follow this Question
Related Questions
Make rolling ball player spin script 1 Answer
how to find tags 0 Answers
Enabling/Disabling Multiple Tagged objects 1 Answer
Creating tags via code 3 Answers
Same objects doing the same thing 0 Answers