diff --git a/Assets/Fungus/Dialog/Commands/Say.cs b/Assets/Fungus/Dialog/Commands/Say.cs index c738d4e5..50f939d1 100644 --- a/Assets/Fungus/Dialog/Commands/Say.cs +++ b/Assets/Fungus/Dialog/Commands/Say.cs @@ -46,10 +46,7 @@ namespace Fungus.Script dialogController.ShowDialog(true); - if (character != null) - { - dialogController.SetCharacter(character); - } + dialogController.SetCharacter(character); if (options.Count > 0) { diff --git a/Assets/Fungus/Dialog/Editor/SayEditor.cs b/Assets/Fungus/Dialog/Editor/SayEditor.cs index facc843e..f8174e0c 100644 --- a/Assets/Fungus/Dialog/Editor/SayEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SayEditor.cs @@ -21,15 +21,15 @@ namespace Fungus.Script EditorGUI.BeginChangeCheck(); + Character character = FungusCommandEditor.ObjectField(new GUIContent("Character", "Character to display in dialog"), + new GUIContent(""), + t.character); + EditorGUILayout.PrefixLabel(new GUIContent("Say Text", "Text to display in dialog")); GUIStyle sayStyle = new GUIStyle(EditorStyles.textArea); sayStyle.wordWrap = true; string text = EditorGUILayout.TextArea(t.storyText, sayStyle, GUILayout.MinHeight(30)); - Character character = EditorGUILayout.ObjectField(new GUIContent("Character", "Character to display in dialog"), - t.character, - typeof(Character), true) as Character; - bool displayOnce = EditorGUILayout.Toggle(new GUIContent("Display Once", "Display this text once and never show it again."), t.displayOnce); if (EditorGUI.EndChangeCheck()) diff --git a/Assets/Fungus/Dialog/Scripts/DialogController.cs b/Assets/Fungus/Dialog/Scripts/DialogController.cs index b17b52cd..6446c6e7 100644 --- a/Assets/Fungus/Dialog/Scripts/DialogController.cs +++ b/Assets/Fungus/Dialog/Scripts/DialogController.cs @@ -44,11 +44,18 @@ namespace Fungus.Script { if (character == null) { - return; + if (leftImage != null) + leftImage.enabled = false; + if (rightImage != null) + rightImage.enabled = false; + if (nameText != null) + nameText.text = ""; + } + else + { + SetCharacterImage(character.characterImage, character.dialogSide); + SetCharacterName(character.name, character.characterColor); } - - SetCharacterImage(character.characterImage, character.dialogSide); - SetCharacterName(character.name, character.characterColor); } public void SetCharacterImage(Sprite image, DialogSide side) diff --git a/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs index d9739e8a..cce7aaec 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs @@ -168,6 +168,38 @@ namespace Fungus.Script } return copy as T; } + + static public T ObjectField(GUIContent label, GUIContent nullLabel, T selectedObject) where T : MonoBehaviour + { + List objectNames = new List(); + + int selectedIndex = 0; + objectNames.Add(nullLabel); + T[] objects = GameObject.FindObjectsOfType(); + for (int i = 0; i < objects.Length; ++i) + { + objectNames.Add(new GUIContent(objects[i].name)); + + if (selectedObject == objects[i]) + { + selectedIndex = i + 1; + } + } + + T result; + + selectedIndex = EditorGUILayout.Popup(label, selectedIndex, objectNames.ToArray()); + if (selectedIndex == 0) + { + result = null; // Null option + } + else + { + result = objects[selectedIndex - 1]; + } + + return result; + } } } diff --git a/Assets/Shuttle/NewDialog.unity b/Assets/Shuttle/NewDialog.unity index 7917e9ba..3eb876d0 100644 Binary files a/Assets/Shuttle/NewDialog.unity and b/Assets/Shuttle/NewDialog.unity differ