Spelunx Cavern SDK
 
Loading...
Searching...
No Matches
TagUtil.cs
Go to the documentation of this file.
1using UnityEditor;
2using UnityEngine;
3
4namespace Spelunx {
5 public class TagUtil {
6 private TagUtil() { }
7
8 public static void AddTag(string tag) {
9 UnityEngine.Object[] asset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");
10 if ((asset != null) && (asset.Length > 0)) {
11 SerializedObject so = new SerializedObject(asset[0]);
12 SerializedProperty tags = so.FindProperty("tags");
13
14 // check if tag is already present in tag list
15 for (int i = 0; i < tags.arraySize; ++i) {
16 if (tags.GetArrayElementAtIndex(i).stringValue == tag) {
17 return;
18 }
19 }
20
21 tags.InsertArrayElementAtIndex(tags.arraySize);
22 tags.GetArrayElementAtIndex(tags.arraySize - 1).stringValue = tag;
23 so.ApplyModifiedProperties();
24 so.Update();
25 }
26 }
27 }
28}
static void AddTag(string tag)
Definition: TagUtil.cs:8