using UnityEditor; using UnityEngine; using System.Collections; using System.Collections.Generic; using Fungus; [CustomEditor (typeof(SequenceController))] public class SequenceControllerEditor : Editor { public override void OnInspectorGUI() { SequenceController t = target as SequenceController; t.stepTime = EditorGUILayout.FloatField("Step Time", t.stepTime); t.startSequence = SequenceEditor.SequenceField("Start Sequence", t, t.startSequence); if (t.startSequence == null) { GUIStyle style = new GUIStyle(GUI.skin.label); style.normal.textColor = new Color(1,0,0); EditorGUILayout.LabelField(new GUIContent("Error: Please select a Start Sequence"), style); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Open Fungus Editor")) { EditorWindow.GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor"); } if (GUILayout.Button("New Sequence")) { GameObject go = new GameObject("Sequence"); go.transform.parent = t.transform; Sequence s = go.AddComponent(); FungusEditorWindow fungusEditorWindow = EditorWindow.GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor") as FungusEditorWindow; s.nodeRect.x = fungusEditorWindow.scrollPos.x; s.nodeRect.y = fungusEditorWindow.scrollPos.y; Undo.RegisterCreatedObjectUndo(go, "Sequence"); Selection.activeGameObject = go; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }