public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(); // Collection Label EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField($"{target.name}"); if (GUILayout.Button("Clean Collection")) { soundTagCollection.Cleanse(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(20); if (GUILayout.Button("+ Add Item")) { soundTagCollection.AddItem(null, SurfaceTag.None); } EditorGUILayout.Space(20); // List<MaterialTagItem> collectionItems = soundTagCollection.ItemTags; List <Material> materials = soundTagCollection.materials; List <SurfaceTag> tags = soundTagCollection.tags; List <MaterialTagItem> itemsForDelete = new List <MaterialTagItem>(); // Parameter settings for (int i = 0; i < materials.Count; ++i) { EditorGUILayout.BeginHorizontal(); Material mat = (Material)EditorGUILayout.ObjectField(materials[i], typeof(Material), false); SurfaceTag tag = (SurfaceTag)EditorGUILayout.EnumPopup(tags[i]); soundTagCollection.UpdateItem(i, mat, tag); if (GUILayout.Button("x")) { itemsForDelete.Add(new MaterialTagItem(mat, tag)); } EditorGUILayout.EndHorizontal(); } // Purge items after iterative process foreach (MaterialTagItem entry in itemsForDelete) { soundTagCollection.RemoveItem(entry); } EditorGUILayout.EndVertical(); }
public void UpdateItem(int idx, Material mat, SurfaceTag tag) { materials[idx] = mat; tags[idx] = tag; }
public void AddItem(Material mat, SurfaceTag tag) { materials.Add(mat); tags.Add(tag); }
public MaterialTagItem(Material m, SurfaceTag t) { this.mat = m; this.name = mat != null ? m.name : ""; this.tag = (int)t; }
public MaterialTagItem(string m, SurfaceTag t) { this.name = m; this.tag = (int)t; this.mat = null; }