-
Notifications
You must be signed in to change notification settings - Fork 4
/
Pooled.cs
44 lines (33 loc) · 1.12 KB
/
Pooled.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections;
using clojure.lang;
public class Pooled : MonoBehaviour{
public IFn recycler;
public void onDestroy(){
}
public static void addTag(string name){
#if UNITY_EDITOR
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
SerializedProperty tagsProp = tagManager.FindProperty("tags");
SerializedProperty layersProp = tagManager.FindProperty("layers");
bool found = false;
for (int i = 0; i < tagsProp.arraySize; i++)
{
SerializedProperty t = tagsProp.GetArrayElementAtIndex(i);
if (t.stringValue.Equals(name)) { found = true; break; }
}
if (!found)
{
tagsProp.InsertArrayElementAtIndex(0);
SerializedProperty n = tagsProp.GetArrayElementAtIndex(0);
n.stringValue = name;
}
SerializedProperty _spasdf = layersProp.GetArrayElementAtIndex(10);
if (_spasdf != null) _spasdf.stringValue = name;
tagManager.ApplyModifiedProperties();
#endif
}
}