From b405c1318eae05fd2c2170e8ee7a8feb69393db5 Mon Sep 17 00:00:00 2001 From: FeniXb3 Date: Fri, 11 Dec 2015 01:01:17 +0100 Subject: [PATCH] Added ability to set say dialog per character - usefull if you want to have separate say dialogs for each character --- Assets/Fungus/Narrative/Editor/CharacterEditor.cs | 12 ++++++++---- Assets/Fungus/Narrative/Scripts/Character.cs | 7 +++++-- Assets/Fungus/Narrative/Scripts/Commands/Say.cs | 9 +++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Assets/Fungus/Narrative/Editor/CharacterEditor.cs b/Assets/Fungus/Narrative/Editor/CharacterEditor.cs index cc2d662d..5ea493ae 100644 --- a/Assets/Fungus/Narrative/Editor/CharacterEditor.cs +++ b/Assets/Fungus/Narrative/Editor/CharacterEditor.cs @@ -16,8 +16,9 @@ namespace Fungus protected SerializedProperty portraitsProp; protected SerializedProperty portraitsFaceProp; protected SerializedProperty descriptionProp; + protected SerializedProperty setSayDialogProp; - protected virtual void OnEnable() + protected virtual void OnEnable() { nameTextProp = serializedObject.FindProperty ("nameText"); nameColorProp = serializedObject.FindProperty ("nameColor"); @@ -25,7 +26,8 @@ namespace Fungus portraitsProp = serializedObject.FindProperty ("portraits"); portraitsFaceProp = serializedObject.FindProperty ("portraitsFace"); descriptionProp = serializedObject.FindProperty ("description"); - } + setSayDialogProp = serializedObject.FindProperty("setSayDialog"); + } public override void OnInspectorGUI() { @@ -36,8 +38,10 @@ namespace Fungus EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog")); EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog")); EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog.")); - EditorGUILayout.PropertyField(descriptionProp, new GUIContent("Description", "Notes about this story character (personality, attibutes, etc.)")); - if (t.portraits != null && + EditorGUILayout.PropertyField(setSayDialogProp); + EditorGUILayout.PropertyField(descriptionProp, new GUIContent("Description", "Notes about this story character (personality, attibutes, etc.)")); + + if (t.portraits != null && t.portraits.Count > 0) { t.profileSprite = t.portraits[0]; diff --git a/Assets/Fungus/Narrative/Scripts/Character.cs b/Assets/Fungus/Narrative/Scripts/Character.cs index 4d644f0e..251c00a3 100644 --- a/Assets/Fungus/Narrative/Scripts/Character.cs +++ b/Assets/Fungus/Narrative/Scripts/Character.cs @@ -16,9 +16,12 @@ namespace Fungus public Sprite profileSprite; public List portraits; public FacingDirection portraitsFace; - public PortraitState state; + public PortraitState state; + + [Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")] + public SayDialog setSayDialog; - [FormerlySerializedAs("notes")] + [FormerlySerializedAs("notes")] [TextArea(5,10)] public string description; diff --git a/Assets/Fungus/Narrative/Scripts/Commands/Say.cs b/Assets/Fungus/Narrative/Scripts/Commands/Say.cs index 03536ab3..c6c56f1a 100644 --- a/Assets/Fungus/Narrative/Scripts/Commands/Say.cs +++ b/Assets/Fungus/Narrative/Scripts/Commands/Say.cs @@ -57,8 +57,13 @@ namespace Fungus executionCount++; - // Override the active say dialog if needed - if (setSayDialog != null) + // Override the active say dialog if needed + if (character != null && character.setSayDialog != null) + { + SayDialog.activeSayDialog = character.setSayDialog; + } + + if (setSayDialog != null) { SayDialog.activeSayDialog = setSayDialog; }