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(); this.ShowSemanticLabels(sc); } private void ShowSemanticLabels(SceneController sc) { showLabels = EditorGUILayout.BeginFoldoutHeaderGroup(showLabels, "Semantic labels"); if (showLabels) { if (sc.semanticBehaviours == null || GUILayout.Button("Refresh list of semantic labels")) { sc.FindSemanticLabels(); } foreach (SemanticBehaviour sb in sc.semanticBehaviours) { string label = sb.GetComponent().name; if (sb.is_a.Count() > 0) { label += $" a {sb.is_a.Split('#')[1]}"; } EditorGUILayout.ObjectField(label, sb.gameObject, typeof(GameObject), true); } } } } }