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
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
45
46
47
48
using UnityEngine;
using UnityEditor;
using System.Linq;

namespace dlu
{

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

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


        EditorGUILayout.Space();
        ShowSemanticLabels();
    }

    private void ShowSemanticLabels()
    {
        showLabels = EditorGUILayout.BeginFoldoutHeaderGroup(showLabels, "Semantic labels");

        if (showLabels)
        {
            if (semanticLabels == null || GUILayout.Button("Refresh list of semantic labels"))
            {
                semanticLabels = GameObject.FindObjectsOfType<SemanticLabel>();
            }

            foreach (SemanticLabel sl in semanticLabels)
            {
                string label = sl.name;
                if (sl.is_a.Count() > 0)
                {
                    label += $" a {sl.is_a[0].Split('#')[1]}";
                }
                EditorGUILayout.ObjectField(label, sl.gameObject, typeof(GameObject), true);
            }
        }
    }
}

}