diff --git a/Assets/Fungus/Dialog/Commands/Choose.cs b/Assets/Fungus/Dialog/Commands/Choose.cs index 9850a37a..e8e049d5 100644 --- a/Assets/Fungus/Dialog/Commands/Choose.cs +++ b/Assets/Fungus/Dialog/Commands/Choose.cs @@ -24,6 +24,8 @@ namespace Fungus.Script public Character character; public float timeoutDuration; + bool showBasicGUI; + public override void OnEnter() { // Remember active dialog between Choose calls @@ -31,7 +33,7 @@ namespace Fungus.Script { if (Choose.activeDialog == null) { - Continue(); + showBasicGUI = true; return; } else @@ -109,6 +111,51 @@ namespace Fungus.Script } } } + + void OnGUI() + { + if (!showBasicGUI) + { + return; + } + + // Draw a basic GUI to use when no uGUI dialog has been set + // Does not support drawing character images + + GUILayout.BeginHorizontal(GUILayout.Width(Screen.width)); + GUILayout.FlexibleSpace(); + + GUILayout.BeginVertical(GUILayout.Height(Screen.height)); + GUILayout.FlexibleSpace(); + + GUILayout.BeginVertical(new GUIStyle(GUI.skin.box)); + + if (character != null) + { + GUILayout.Label(character.characterName); + GUILayout.Space(10); + } + + GUILayout.Label(chooseText); + + foreach (Option option in options) + { + if (GUILayout.Button(option.optionText)) + { + options.Clear(); + showBasicGUI = false; + ExecuteSequence(option.targetSequence); + } + } + + GUILayout.EndVertical(); + + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Commands/Say.cs b/Assets/Fungus/Dialog/Commands/Say.cs index 385d8464..bdc3814d 100644 --- a/Assets/Fungus/Dialog/Commands/Say.cs +++ b/Assets/Fungus/Dialog/Commands/Say.cs @@ -18,6 +18,8 @@ namespace Fungus.Script public bool showOnce; int executionCount; + bool showBasicGUI; + public override void OnEnter() { if (showOnce && executionCount > 0) @@ -33,7 +35,7 @@ namespace Fungus.Script { if (activeDialog == null) { - Continue(); + showBasicGUI = true; return; } else @@ -68,6 +70,46 @@ namespace Fungus.Script return summary; } + + void OnGUI() + { + if (!showBasicGUI) + { + return; + } + + // Draw a basic GUI to use when no uGUI dialog has been set + // Does not support drawing character images + + GUILayout.BeginHorizontal(GUILayout.Width(Screen.width)); + GUILayout.FlexibleSpace(); + + GUILayout.BeginVertical(GUILayout.Height(Screen.height)); + GUILayout.FlexibleSpace(); + + GUILayout.BeginVertical(new GUIStyle(GUI.skin.box)); + + if (character != null) + { + GUILayout.Label(character.characterName); + GUILayout.Space(10); + } + + GUILayout.Label(storyText); + if (GUILayout.Button("Continue")) + { + showBasicGUI = false; + Continue(); + } + + GUILayout.EndVertical(); + + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs index a1e15aed..8b827344 100644 --- a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs +++ b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs @@ -50,16 +50,15 @@ namespace Fungus.Script if (characterImage != null && spriteMaterial != null) { - float aspect = (float)characterImage.texture.width / (float)characterImage.texture.height; - EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); + float aspect = (float)characterImage.texture.width / (float)characterImage.texture.height; Rect imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(150), GUILayout.ExpandWidth(false)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); - EditorGUI.DrawPreviewTexture(imagePreviewRect, - characterImage.texture, - spriteMaterial); + + DrawPreview(imagePreviewRect, + characterImage.texture); } if (EditorGUI.EndChangeCheck()) @@ -72,6 +71,17 @@ namespace Fungus.Script t.dialogSide = dialogSide; } } + + public void DrawPreview(Rect previewRect, Texture2D texture) + { + if (texture == null) + { + return; + } + EditorGUI.DrawPreviewTexture(previewRect, + texture, + spriteMaterial); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Editor/SayEditor.cs b/Assets/Fungus/Dialog/Editor/SayEditor.cs index 8dd51519..793bfe21 100644 --- a/Assets/Fungus/Dialog/Editor/SayEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SayEditor.cs @@ -17,11 +17,33 @@ namespace Fungus.Script EditorGUI.BeginChangeCheck(); - 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)); + + EditorGUILayout.BeginHorizontal(); + + string text = EditorGUILayout.TextArea(t.storyText, sayStyle, GUILayout.MinHeight(40)); + + if (t.character != null && + t.character.characterImage != null && + t.character.characterImage.texture != null) + { + Texture2D characterTexture = t.character.characterImage.texture; + + float aspect = (float)characterTexture.width / (float)characterTexture.height; + Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(40), GUILayout.ExpandWidth(false)); + CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor; + if (characterEditor != null) + { + characterEditor.DrawPreview(previewRect, characterTexture); + } + } + + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.Separator(); Character character = FungusCommandEditor.ObjectField(new GUIContent("Character", "Character to display in dialog"), new GUIContent(""), diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 74c45dc6..50169609 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ