SceneControllerEditor.cs 1.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using UnityEngine;
using UnityEditor;
using System.Linq;

namespace dlu
{

[CustomEditor(typeof(SceneController))]
public class SceneControllerEditor : Editor
{
    private bool showLabels;

    public override void OnInspectorGUI()
    {
        SceneController sc = (SceneController) target;
        base.DrawDefaultInspector();


        EditorGUILayout.Space();
20
        this.ShowSemanticLabels(sc);
21
22
    }

23
    private void ShowSemanticLabels(SceneController sc)
24
25
26
27
28
    {
        showLabels = EditorGUILayout.BeginFoldoutHeaderGroup(showLabels, "Semantic labels");

        if (showLabels)
        {
29
            if (sc.semanticBehaviours == null || GUILayout.Button("Refresh list of semantic labels"))
30
            {
31
                sc.FindSemanticLabels();
32
33
            }

34
            foreach (SemanticBehaviour sb in sc.semanticBehaviours)
35
            {
36
37
                string label = sb.GetComponent<InstanceIdentifier>().name;
                if (sb.is_a.Count() > 0)
38
                {
39
                    label += $" a {sb.is_a.Split('#')[1]}";
40
                }
41
                EditorGUILayout.ObjectField(label, sb.gameObject, typeof(GameObject), true);
42
43
44
45
46
47
            }
        }
    }
}

}