Hello all,
I noticed that there’s something looking like tags for textures and materials in Unity Editor :
The little “tag” button in the bottom right corner allow me to assign and create new tags.
How can I retrieve those tags in Unity script ? I’d like to be able to switch some materials in the scene according to a tag classification. I managed to do this upon materials name (i.e. including “Floor” or “Wall” in material name, and the using material.name.IndexOf(objectsTag) != -1), but I’d like to find a better way.
I have tried using the Material.GetTag method, but it looks like I didn’t get how it works :
for (var material in allMaterials) {
var result:String = material.GetTag(tag, false, "nope");
Debug.Log(result);
if (result != "nope") {
taggedMaterials.push(material);
}
}
Thank you for letting me know what I’ve done wrong, or if there’s a better way to achieve this.