//Draws editable list of keys void OnGUI() { reader = (DialogueReader)EditorUtility.InstanceIDToObject(instanceId); if (reader != null) { int spacer = 10; EditorGUIUtility.labelWidth = 80; GUILayout.BeginArea(new Rect(spacer, spacer, position.width - spacer * 2, position.height - spacer * 2), GUI.skin.box); EditorGUILayout.LabelField("Key List", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold)); GUILayout.Space(spacer); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Name", EditorStyles.label)) { SortKeys("name"); } if (GUILayout.Button("Number", EditorStyles.label, GUILayout.Width(position.width / 5))) { SortKeys("number"); } EditorGUILayout.EndHorizontal(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); for (int i = 0; i < reader.Keys.Count; i++) { Key key = reader.Keys[i]; EditorGUILayout.BeginHorizontal(); key.name = EditorGUILayout.TextField(key.name); key.number = EditorGUILayout.IntField(key.number, GUILayout.Width(position.width / 5)); if (GUILayout.Button("Delete")) { reader.Keys.Remove(key); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); newName = EditorGUILayout.TextField(newName); newNum = EditorGUILayout.IntField(newNum, GUILayout.Width(position.width / 5)); if (GUILayout.Button("Create")) { CreateNewKey(newName, newNum); } EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); } if (GUI.changed) { EditorUtility.SetDirty(reader); } }
//Draws actor list, and properties for selected actor void DrawActors() { float spacer = 10; GUILayout.BeginArea(new Rect(spacer, spacer, position.width - spacer * 2, position.height - spacer * 2)); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(position.width * 0.4f - spacer * 2)); EditorGUILayout.LabelField("Actor List", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold)); GUILayout.Space(spacer); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); for (int i = 0; i < reader.actors.Count; i++) { Actor actor = reader.actors[i]; GUIStyle style = (selectedActor == actor) ? EditorStyles.boldLabel : EditorStyles.label; GUILayout.BeginHorizontal(); if (GUILayout.Button(actor.name, style)) { selectedActor = actor; GUI.FocusControl(""); } if (GUILayout.Button("▲", GUILayout.Width(25))) { MoveActor(actor, "up"); } if (GUILayout.Button("▼", GUILayout.Width(25))) { MoveActor(actor, "down"); } if (GUILayout.Button("Delete", GUILayout.Width(50))) { DeleteActor(actor); } GUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Create Actor")) { CreateActor(); } GUILayout.EndVertical(); GUILayout.Space(spacer); GUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(position.width * 0.6f - spacer)); EditorGUILayout.LabelField("Actor Properties", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold)); GUILayout.Space(spacer); if (selectedActor != null) { selectedActor.name = EditorGUILayout.TextField("Name: ", selectedActor.name); selectedActor.positionType = (Actor.PositionType)EditorGUILayout.EnumPopup("Position Type ", selectedActor.positionType); if (selectedActor.positionType == Actor.PositionType.Dynamic) { selectedActor.transform = (Transform)EditorGUILayout.ObjectField("Transform: ", selectedActor.transform, typeof(Transform), true); selectedActor.autoPosition = EditorGUILayout.Toggle("Auto Position: ", selectedActor.autoPosition); selectedActor.offset = EditorGUILayout.Vector3Field("Offset", selectedActor.offset); } else { selectedActor.position = (TextAnchor)EditorGUILayout.EnumPopup("Position ", selectedActor.position); selectedActor.offset = EditorGUILayout.Vector2Field("Offset", selectedActor.offset); } selectedActor.image = (Texture2D)EditorGUILayout.ObjectField("Image: ", selectedActor.image, typeof(Texture2D), true); if (selectedActor.image) { selectedActor.imageRight = EditorGUILayout.Toggle("Switch Side: ", selectedActor.imageRight); } GUILayout.FlexibleSpace(); } else { GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }