Пример #1
0
    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();
    }
Пример #2
0
 public void UpdateItem(int idx, Material mat, SurfaceTag tag)
 {
     materials[idx] = mat;
     tags[idx]      = tag;
 }
Пример #3
0
 public void AddItem(Material mat, SurfaceTag tag)
 {
     materials.Add(mat);
     tags.Add(tag);
 }
Пример #4
0
 public MaterialTagItem(Material m, SurfaceTag t)
 {
     this.mat  = m;
     this.name = mat != null ? m.name : "";
     this.tag  = (int)t;
 }
Пример #5
0
 public MaterialTagItem(string m, SurfaceTag t)
 {
     this.name = m;
     this.tag  = (int)t;
     this.mat  = null;
 }