diff --git a/Assets/Fungus/Narrative/Resources/SayDialog.prefab b/Assets/Fungus/Narrative/Resources/SayDialog.prefab index ccf38d1c..25104662 100644 --- a/Assets/Fungus/Narrative/Resources/SayDialog.prefab +++ b/Assets/Fungus/Narrative/Resources/SayDialog.prefab @@ -557,7 +557,7 @@ MonoBehaviour: m_Calls: [] m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 21300000, guid: eeb00f6cd27e9ef4d9174551b3342dec, type: 3} + m_Sprite: {fileID: 21300000, guid: e8ab00ef0d9684dcb9deb52811d91218, type: 3} m_Type: 1 m_PreserveAspect: 1 m_FillCenter: 1 diff --git a/Assets/Fungus/Narrative/Scripts/ConversationManager.cs b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs index eefa8b4c..3248a9f7 100644 --- a/Assets/Fungus/Narrative/Scripts/ConversationManager.cs +++ b/Assets/Fungus/Narrative/Scripts/ConversationManager.cs @@ -26,15 +26,23 @@ namespace Fungus characters = UnityEngine.Object.FindObjectsOfType(); } - protected Stage GetActiveStage() + protected SayDialog GetSayDialog(Character character) { - if (Stage.activeStages == null || - Stage.activeStages.Count == 0) + SayDialog sayDialog = null; + if (character != null) { - return null; + if (character.setSayDialog != null) + { + sayDialog = character.setSayDialog; + } + } + + if (sayDialog == null) + { + sayDialog = SayDialog.GetSayDialog(); } - return Stage.activeStages[0]; + return sayDialog; } /// @@ -48,25 +56,17 @@ namespace Fungus yield break; } - SayDialog sayDialog = SayDialog.GetSayDialog(); - - if (sayDialog == null) - { - yield break; - } - var conversationItems = Parse(conv); - // Play the conversation - + // Track the current and previous parameter values Character currentCharacter = null; Sprite currentPortrait = null; RectTransform currentPosition = null; - Character previousCharacter = null; Sprite previousPortrait = null; RectTransform previousPosition = null; + // Play the conversation for (int i = 0; i < conversationItems.Count; ++i) { ConversationItem item = conversationItems[i]; @@ -86,6 +86,14 @@ namespace Fungus currentPosition = item.Position; } + SayDialog sayDialog = GetSayDialog(currentCharacter); + + if (sayDialog == null) + { + // Should never happen + yield break; + } + sayDialog.gameObject.SetActive(true); if (currentCharacter != null && @@ -94,7 +102,7 @@ namespace Fungus sayDialog.SetCharacter(currentCharacter); } - Stage stage = GetActiveStage(); + Stage stage = Stage.GetActiveStage(); if (stage != null && currentCharacter != null && @@ -236,7 +244,7 @@ namespace Fungus } // Next check if there's a position parameter - Stage stage = GetActiveStage(); + Stage stage = Stage.GetActiveStage(); if (stage != null) { for (int i = 0; i < sayParams.Length; i++) diff --git a/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity b/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity index eb94a07c..b213dda0 100644 --- a/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity +++ b/Assets/FungusExamples/FungusLua/Narrative/PortaitControlExample.unity @@ -232,7 +232,7 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 2 --- !u!1 &574033265 GameObject: m_ObjectHideFlags: 0 @@ -343,7 +343,7 @@ MonoBehaviour: m_EditorClassIdentifier: nodeRect: serializedVersion: 2 - x: 69.066124 + x: 70.09919 y: 68.96694 width: 120 height: 40 @@ -406,7 +406,7 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 --- !u!114 &574033271 MonoBehaviour: m_ObjectHideFlags: 2 @@ -442,6 +442,9 @@ MonoBehaviour: angry: Wait, no I don''t! + watson: Whatever man. + + ]] ' @@ -524,6 +527,101 @@ MonoBehaviour: type: 2} m_PrefabInternal: {fileID: 2059718440} m_Script: {fileID: 11500000, guid: 6f6478b25a400c642b2dee75f022ab12, type: 3} +--- !u!1001 &665255988 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_RootOrder + value: 10 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Pivot.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Pivot.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 188902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11488904, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: c207de86481ff7d48a2fba2fcc374723, + type: 3} + - target: {fileID: 188902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Name + value: WatsonSayDialog + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + m_IsPrefabParent: 0 --- !u!1 &682432115 GameObject: m_ObjectHideFlags: 0 @@ -604,7 +702,7 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 --- !u!1 &856587351 GameObject: m_ObjectHideFlags: 0 @@ -679,7 +777,108 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 10 +--- !u!114 &1231398849 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 11488894, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, + type: 2} + m_PrefabInternal: {fileID: 665255988} + m_Script: {fileID: 11500000, guid: 3a0bbe22c246e4c78ad8e9816cbae9d5, type: 3} +--- !u!1001 &1571865516 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Pivot.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Pivot.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 188902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11488904, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: 888feb4a32e3b564fb7e6f9b28cc8e10, + type: 3} + - target: {fileID: 188902, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + propertyPath: m_Name + value: SherlockSayDialog + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, type: 2} + m_IsPrefabParent: 0 --- !u!1 &1756024128 GameObject: m_ObjectHideFlags: 1 @@ -720,7 +919,7 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 --- !u!1 &1818980091 GameObject: m_ObjectHideFlags: 0 @@ -757,7 +956,7 @@ MonoBehaviour: - {fileID: 21300000, guid: a92b08a118b7d46f59dd091acb2e4102, type: 3} - {fileID: 21300000, guid: 03bc547cc0049594bae51f00903eedef, type: 3} portraitsFace: 0 - setSayDialog: {fileID: 0} + setSayDialog: {fileID: 1231398849} description: --- !u!4 &1818980093 Transform: @@ -771,7 +970,7 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 --- !u!1 &1876668763 GameObject: m_ObjectHideFlags: 0 @@ -808,7 +1007,7 @@ MonoBehaviour: - {fileID: 21300000, guid: 8f5b5b110e73a414eb229eeead86200f, type: 3} - {fileID: 21300000, guid: c779e34c6eb8e45da98c70cf2802a54c, type: 3} portraitsFace: 0 - setSayDialog: {fileID: 0} + setSayDialog: {fileID: 1958712152} description: --- !u!4 &1876668765 Transform: @@ -822,7 +1021,13 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 +--- !u!114 &1958712152 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 11488894, guid: 8a005a9e0713f4cc1b5ad29fb07657d3, + type: 2} + m_PrefabInternal: {fileID: 1571865516} + m_Script: {fileID: 11500000, guid: 3a0bbe22c246e4c78ad8e9816cbae9d5, type: 3} --- !u!1001 &2059718440 Prefab: m_ObjectHideFlags: 0 @@ -860,7 +1065,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 410270, guid: c6289d5f8fa843145a2355af9cb09719, type: 2} propertyPath: m_RootOrder - value: 2 + value: 3 objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: c6289d5f8fa843145a2355af9cb09719, type: 2}