From 1a05f892269bf6b75b55aa9723131eb336c0e919 Mon Sep 17 00:00:00 2001 From: Michal Pikulski Date: Wed, 8 Oct 2025 10:51:14 +0200 Subject: [PATCH 1/3] First pass on the image drawing --- .../Editor/Dialogue/DialogueContentDrawer.cs | 126 ++++++++++++ .../Dialogue/DialogueContentDrawer.cs.meta | 3 + Assets/Prefabs/UI/DialogueCanvas.prefab | 141 ++++++++++++-- .../Scenes/Levels/AppleHillsOverworld.unity | 10 +- Assets/Scenes/Levels/Quarry.unity | 61 ++---- Assets/Scripts/Dialogue/DialogueComponent.cs | 183 ++++++++++++++---- Assets/Scripts/Dialogue/DialogueContent.cs | 76 ++++++++ .../Scripts/Dialogue/DialogueContent.cs.meta | 3 + .../Scripts/Dialogue/RuntimeDialogueGraph.cs | 11 +- Assets/Scripts/Dialogue/SpeechBubble.cs | 131 ++++++++++++- .../Dialogue/SpeechBubbleController.cs | 1 - .../Dialogue/SpeechBubbleController.cs.meta | 3 - 12 files changed, 645 insertions(+), 104 deletions(-) create mode 100644 Assets/Editor/Dialogue/DialogueContentDrawer.cs create mode 100644 Assets/Editor/Dialogue/DialogueContentDrawer.cs.meta create mode 100644 Assets/Scripts/Dialogue/DialogueContent.cs create mode 100644 Assets/Scripts/Dialogue/DialogueContent.cs.meta delete mode 100644 Assets/Scripts/Dialogue/SpeechBubbleController.cs delete mode 100644 Assets/Scripts/Dialogue/SpeechBubbleController.cs.meta diff --git a/Assets/Editor/Dialogue/DialogueContentDrawer.cs b/Assets/Editor/Dialogue/DialogueContentDrawer.cs new file mode 100644 index 00000000..d149e13b --- /dev/null +++ b/Assets/Editor/Dialogue/DialogueContentDrawer.cs @@ -0,0 +1,126 @@ +using UnityEditor; +using UnityEngine; + +namespace Dialogue.Editor +{ + /// + /// Custom property drawer for DialogueContent that displays either text or image fields based on content type + /// + [CustomPropertyDrawer(typeof(DialogueContent))] + public class DialogueContentDrawer : PropertyDrawer + { + // Height constants + private const float TypeSelectorHeight = 20f; + private const float PropertySpacing = 2f; + private const float TextFieldHeight = 40f; // Taller for multi-line text + private const float ImageFieldHeight = 18f; + private const float PreviewHeight = 64f; + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + var contentTypeProperty = property.FindPropertyRelative("_contentType"); + var height = TypeSelectorHeight + PropertySpacing; + + // Add height based on content type + if (contentTypeProperty.enumValueIndex == (int)DialogueContentType.Text) + { + height += TextFieldHeight; + } + else // Image + { + height += ImageFieldHeight; + + // Add preview height if an image is assigned + var imageProperty = property.FindPropertyRelative("_image"); + if (imageProperty.objectReferenceValue != null) + { + height += PropertySpacing + PreviewHeight; + } + } + + return height; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUI.BeginProperty(position, label, property); + + // Create a property field and indent it + var contentRect = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); + var indent = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + + // Get properties + var contentTypeProperty = property.FindPropertyRelative("_contentType"); + var textProperty = property.FindPropertyRelative("_text"); + var imageProperty = property.FindPropertyRelative("_image"); + + // Calculate rects + var typeRect = new Rect(contentRect.x, contentRect.y, contentRect.width, TypeSelectorHeight); + var contentFieldRect = new Rect( + contentRect.x, + contentRect.y + TypeSelectorHeight + PropertySpacing, + contentRect.width, + contentTypeProperty.enumValueIndex == (int)DialogueContentType.Text ? TextFieldHeight : ImageFieldHeight); + + // Draw the content type dropdown + EditorGUI.PropertyField(typeRect, contentTypeProperty, GUIContent.none); + + // Draw the appropriate field based on content type + if (contentTypeProperty.enumValueIndex == (int)DialogueContentType.Text) + { + // Text field with word wrap for multi-line input + textProperty.stringValue = EditorGUI.TextArea(contentFieldRect, textProperty.stringValue); + } + else // Image + { + // Draw the image field + EditorGUI.PropertyField(contentFieldRect, imageProperty, GUIContent.none); + + // Draw a preview if an image is assigned + if (imageProperty.objectReferenceValue != null) + { + var sprite = imageProperty.objectReferenceValue as Sprite; + if (sprite != null) + { + var previewRect = new Rect( + contentRect.x, + contentFieldRect.y + contentFieldRect.height + PropertySpacing, + contentRect.width, + PreviewHeight); + + // Draw the preview with preserved aspect ratio + DrawSpritePreview(previewRect, sprite); + } + } + } + + EditorGUI.indentLevel = indent; + EditorGUI.EndProperty(); + } + + private void DrawSpritePreview(Rect position, Sprite sprite) + { + if (sprite == null || sprite.texture == null) return; + + // Calculate aspect-preserved rect + float aspectRatio = sprite.rect.width / sprite.rect.height; + float targetWidth = Mathf.Min(position.width, position.height * aspectRatio); + float targetHeight = targetWidth / aspectRatio; + + // Center the preview + Rect previewRect = new Rect( + position.x + (position.width - targetWidth) * 0.5f, + position.y + (position.height - targetHeight) * 0.5f, + targetWidth, + targetHeight + ); + + // Draw the sprite preview + EditorGUI.DrawPreviewTexture(previewRect, sprite.texture, null, ScaleMode.ScaleToFit); + + // Draw a border around the preview + GUI.Box(previewRect, GUIContent.none); + } + } +} diff --git a/Assets/Editor/Dialogue/DialogueContentDrawer.cs.meta b/Assets/Editor/Dialogue/DialogueContentDrawer.cs.meta new file mode 100644 index 00000000..7245bd85 --- /dev/null +++ b/Assets/Editor/Dialogue/DialogueContentDrawer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f77e7b681b7f464f96242172ea625ed4 +timeCreated: 1759912655 \ No newline at end of file diff --git a/Assets/Prefabs/UI/DialogueCanvas.prefab b/Assets/Prefabs/UI/DialogueCanvas.prefab index 238f4620..40df234a 100644 --- a/Assets/Prefabs/UI/DialogueCanvas.prefab +++ b/Assets/Prefabs/UI/DialogueCanvas.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 9002038557409323574} - component: {fileID: 4498241824153346754} - component: {fileID: 3123748273643935430} + - component: {fileID: 8484489322432759371} m_Layer: 5 m_Name: SpeechBubble m_TagString: Untagged @@ -34,11 +35,11 @@ RectTransform: - {fileID: 1539728007164444029} m_Father: {fileID: 3484825090253933040} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 50} - m_SizeDelta: {x: 400, y: 0} - m_Pivot: {x: 0.5, y: 1} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 600, y: 0} + m_Pivot: {x: 0, y: 0} --- !u!114 &9002038557409323574 MonoBehaviour: m_ObjectHideFlags: 0 @@ -99,6 +100,123 @@ MonoBehaviour: m_FlexibleWidth: -1 m_FlexibleHeight: -1 m_LayoutPriority: 1 +--- !u!114 &8484489322432759371 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1494212192306772670} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cb3605ae81a54d2689504e0cd456ac27, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::Dialogue.SpeechBubble + textDisplay: {fileID: 4573570654593171780} + imageDisplay: {fileID: 4814676392695871198} + displayMode: 1 + typewriterSpeed: 0.05 + typingSoundSource: {fileID: 0} + typingSoundFrequency: 3 + useRichText: 1 + dialogueDisplayTime: 3 + dialoguePromptText: . . . +--- !u!1 &3571537114331005905 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7453431659909988258} + - component: {fileID: 7239040132725875785} + - component: {fileID: 4814676392695871198} + - component: {fileID: 7738447742327076413} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &7453431659909988258 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3571537114331005905} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1539728007164444029} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 300, y: -125} + m_SizeDelta: {x: 200, y: 200} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7239040132725875785 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3571537114331005905} + m_CullTransparentMesh: 1 +--- !u!114 &4814676392695871198 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3571537114331005905} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: -9213056636207805707, guid: 00354ded9d8f8d643acc14837a229544, type: 3} + m_Type: 0 + m_PreserveAspect: 1 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &7738447742327076413 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3571537114331005905} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement + m_IgnoreLayout: 0 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: 200 + m_PreferredHeight: 200 + m_FlexibleWidth: -1 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 --- !u!1 &5048280843231724144 GameObject: m_ObjectHideFlags: 0 @@ -164,7 +282,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Hey there buster! + m_text: Hey there, buster! m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -191,8 +309,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 35 - m_fontSizeBase: 35 + m_fontSize: 55 + m_fontSizeBase: 55 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 @@ -364,18 +482,19 @@ RectTransform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8341977934938436915} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -1} + m_LocalPosition: {x: 0, y: 0, z: -0.9999999} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 7704981663008171144} + - {fileID: 7453431659909988258} m_Father: {fileID: 8307219291215824345} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} + m_Pivot: {x: 0, y: 0} --- !u!222 &2528298462582055986 CanvasRenderer: m_ObjectHideFlags: 0 @@ -433,7 +552,7 @@ MonoBehaviour: m_Bottom: 70 m_ChildAlignment: 4 m_Spacing: 0 - m_ChildForceExpandWidth: 1 + m_ChildForceExpandWidth: 0 m_ChildForceExpandHeight: 0 m_ChildControlWidth: 1 m_ChildControlHeight: 1 diff --git a/Assets/Scenes/Levels/AppleHillsOverworld.unity b/Assets/Scenes/Levels/AppleHillsOverworld.unity index 4fe71ee7..281f320a 100644 --- a/Assets/Scenes/Levels/AppleHillsOverworld.unity +++ b/Assets/Scenes/Levels/AppleHillsOverworld.unity @@ -972,11 +972,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_AnchoredPosition.x - value: 2.55 + value: 0.6806664 objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_AnchoredPosition.y - value: 3.17 + value: 1.4252888 objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -1068,6 +1068,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: AppleHillsScripts::Dialogue.SpeechBubble textDisplay: {fileID: 677854361} + imageDisplay: {fileID: 0} displayMode: 1 typewriterSpeed: 0.02 typingSoundSource: {fileID: 0} @@ -1832,6 +1833,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: AppleHillsScripts::Dialogue.SpeechBubble textDisplay: {fileID: 614125440} + imageDisplay: {fileID: 0} displayMode: 1 typewriterSpeed: 0.02 typingSoundSource: {fileID: 0} @@ -2892,11 +2894,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_AnchoredPosition.x - value: 2.55 + value: 0.5560436 objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_AnchoredPosition.y - value: 3.17 + value: 1.3006666 objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_LocalEulerAnglesHint.x diff --git a/Assets/Scenes/Levels/Quarry.unity b/Assets/Scenes/Levels/Quarry.unity index 1779a87b..fbeb3170 100644 --- a/Assets/Scenes/Levels/Quarry.unity +++ b/Assets/Scenes/Levels/Quarry.unity @@ -1487,31 +1487,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 5145306031820616614, guid: fbbe1f4baf226904b96f839fe0c00181, type: 3} m_PrefabInstance: {fileID: 94815899} m_PrefabAsset: {fileID: 0} ---- !u!1 &103777726 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 1494212192306772670, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} - m_PrefabInstance: {fileID: 1743421791} - m_PrefabAsset: {fileID: 0} ---- !u!114 &103777731 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 103777726} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cb3605ae81a54d2689504e0cd456ac27, type: 3} - m_Name: - m_EditorClassIdentifier: AppleHillsScripts::Dialogue.SpeechBubble - textDisplay: {fileID: 1103549804} - displayMode: 1 - typewriterSpeed: 0.05 - typingSoundSource: {fileID: 0} - typingSoundFrequency: 3 - useRichText: 1 - dialogueDisplayTime: 3 - dialoguePromptText: . . . --- !u!1001 &104952029 PrefabInstance: m_ObjectHideFlags: 0 @@ -446788,17 +446763,6 @@ PrefabInstance: insertIndex: -1 addedObject: {fileID: 21238928} m_SourcePrefab: {fileID: 100100000, guid: 4b7426bc1f8736749b68973653f4dbfb, type: 3} ---- !u!114 &1103549804 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 4573570654593171780, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} - m_PrefabInstance: {fileID: 1743421791} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} - m_Name: - m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI --- !u!1 &1106104746 GameObject: m_ObjectHideFlags: 0 @@ -456563,11 +456527,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_AnchoredPosition.x - value: 2.8 + value: 1.3000008 objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_AnchoredPosition.y - value: 5.34 + value: 3.840001 objectReference: {fileID: 0} - target: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -457644,14 +457608,6 @@ PrefabInstance: propertyPath: m_Camera value: objectReference: {fileID: 1653475492} - - target: {fileID: 4573570654593171780, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} - propertyPath: m_fontSize - value: 80 - objectReference: {fileID: 0} - - target: {fileID: 4573570654593171780, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} - propertyPath: m_fontSizeBase - value: 80 - objectReference: {fileID: 0} - target: {fileID: 6499933157207406972, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} propertyPath: m_Name value: DialogueCanvas @@ -457684,13 +457640,18 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 8307219291215824345, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} + propertyPath: m_AnchoredPosition.x + value: -131.34683 + objectReference: {fileID: 0} + - target: {fileID: 8307219291215824345, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} + propertyPath: m_AnchoredPosition.y + value: -183.88577 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 1494212192306772670, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} - insertIndex: -1 - addedObject: {fileID: 103777731} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3} --- !u!224 &1743421792 stripped RectTransform: diff --git a/Assets/Scripts/Dialogue/DialogueComponent.cs b/Assets/Scripts/Dialogue/DialogueComponent.cs index d66c3d10..4317bdbf 100644 --- a/Assets/Scripts/Dialogue/DialogueComponent.cs +++ b/Assets/Scripts/Dialogue/DialogueComponent.cs @@ -74,19 +74,86 @@ namespace Dialogue private void OnCharacterArrived() { - if (speechBubble == null || ! HasAnyLines()) return; + if (speechBubble == null || !HasAnyLines()) return; AdvanceDialogueState(); - // Get the current dialogue line - string line = GetCurrentDialogueLine(); - - // Display the line with the new method that handles timed updates - speechBubble.DisplayDialogueLine(line, HasAnyLines()); - - // Advance dialogue state for next interaction + // Check if we have DialogueContent available + DialogueContent content = GetCurrentDialogueContent(); + if (content != null) + { + // Display the content with the new method that handles both text and images + speechBubble.DisplayDialogueContent(content, HasAnyLines()); + } + else + { + // Fall back to legacy text-only method + string line = GetCurrentDialogueLine(); + speechBubble.DisplayDialogueLine(line, HasAnyLines()); + } } + /// + /// Get the current dialogue content (text or image) + /// + /// DialogueContent or null if only legacy text content is available + private DialogueContent GetCurrentDialogueContent() + { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + + if (!IsActive || IsCompleted || currentNode == null) + return null; + + // Check if we have DialogueContent available + if (currentNode.dialogueContent != null && currentNode.dialogueContent.Count > 0) + { + // For WaitOnSlot nodes, use the appropriate content based on slot state + if (currentNode.nodeType == RuntimeDialogueNodeType.WaitOnSlot) + { + // Choose the appropriate content collection based on the current slot state + List contentForState = currentNode.dialogueContent; // Default content + + switch (_currentSlotState) + { + case ItemSlotState.Incorrect: + // Use incorrect item content if available + if (currentNode.incorrectItemContent != null && currentNode.incorrectItemContent.Count > 0) + contentForState = currentNode.incorrectItemContent; + break; + + case ItemSlotState.Forbidden: + // Use forbidden item content if available + if (currentNode.forbiddenItemContent != null && currentNode.forbiddenItemContent.Count > 0) + contentForState = currentNode.forbiddenItemContent; + break; + } + + // If we have content for this state, return the current one + if (contentForState != null && contentForState.Count > 0) + { + // Make sure index is within bounds + int index = Mathf.Clamp(currentLineIndex, 0, contentForState.Count - 1); + return contentForState[index]; + } + } + else + { + // For other node types, use the default dialogueContent + if (currentLineIndex >= 0 && currentLineIndex < currentNode.dialogueContent.Count) + { + return currentNode.dialogueContent[currentLineIndex]; + } + } + } + + // No DialogueContent available, will fall back to legacy text handling + return null; + } + private void OnDestroy() { // Unregister from events @@ -205,7 +272,7 @@ namespace Dialogue { if (!IsActive || IsCompleted || currentNode == null) return; - + // If the condition was satisfied earlier, move to the next node immediately if (_conditionSatisfiedPendingAdvance) { @@ -213,21 +280,21 @@ namespace Dialogue MoveToNextNode(); return; } - + // If we have more lines in the current node, advance to the next line if (currentLineIndex < currentNode.dialogueLines.Count - 1) { currentLineIndex++; return; } - + // If we should loop through lines, reset the index if (currentNode.loopThroughLines && currentNode.dialogueLines.Count > 0) { currentLineIndex = 0; return; } - + // If we're at a node that doesn't have a next node, we're done if (string.IsNullOrEmpty(currentNode.nextNodeID)) { @@ -235,7 +302,7 @@ namespace Dialogue IsCompleted = true; return; } - + // Move to the next node only if no conditions to wait for if (!IsWaitingForCondition()) { @@ -560,60 +627,110 @@ namespace Dialogue // Special case: if condition has been satisfied but not yet advanced, we should show lines if (_conditionSatisfiedPendingAdvance && !string.IsNullOrEmpty(currentNode.nextNodeID)) { - // Check if the next node would have lines + // Check if the next node would have lines or content RuntimeDialogueNode nextNode = dialogueGraph.GetNodeByID(currentNode.nextNodeID); - return nextNode != null && (nextNode.dialogueLines.Count > 0 || nextNode.nodeType != RuntimeDialogueNodeType.End); + return nextNode != null && + ((nextNode.dialogueLines != null && nextNode.dialogueLines.Count > 0) || + (nextNode.dialogueContent != null && nextNode.dialogueContent.Count > 0) || + nextNode.nodeType != RuntimeDialogueNodeType.End); } - // For WaitOnSlot nodes, check for lines based on current slot state + // For WaitOnSlot nodes, check for lines or content based on current slot state if (currentNode.nodeType == RuntimeDialogueNodeType.WaitOnSlot) { - // Choose the appropriate line collection based on the current slot state - List linesForState = currentNode.dialogueLines; // Default lines + // First check for DialogueContent + if (currentNode.dialogueContent != null && currentNode.dialogueContent.Count > 0) + { + // Choose the appropriate content collection based on the current slot state + List contentForState = currentNode.dialogueContent; + + switch (_currentSlotState) + { + case ItemSlotState.Incorrect: + if (currentNode.incorrectItemContent != null && currentNode.incorrectItemContent.Count > 0) + contentForState = currentNode.incorrectItemContent; + break; + + case ItemSlotState.Forbidden: + if (currentNode.forbiddenItemContent != null && currentNode.forbiddenItemContent.Count > 0) + contentForState = currentNode.forbiddenItemContent; + break; + } + + if (contentForState.Count > 0) + { + if (currentLineIndex < contentForState.Count - 1 || currentNode.loopThroughLines) + { + return true; + } + } + } + + // Fall back to legacy text lines + List linesForState = currentNode.dialogueLines; switch (_currentSlotState) { case ItemSlotState.Incorrect: - // Use incorrect item lines if available, otherwise fall back to default lines if (currentNode.incorrectItemLines != null && currentNode.incorrectItemLines.Count > 0) linesForState = currentNode.incorrectItemLines; break; case ItemSlotState.Forbidden: - // Use forbidden item lines if available, otherwise fall back to default lines if (currentNode.forbiddenItemLines != null && currentNode.forbiddenItemLines.Count > 0) linesForState = currentNode.forbiddenItemLines; break; } - // Check if we have any lines for the current state if (linesForState != null && linesForState.Count > 0) { - // If we're not at the end of the lines or we loop through them if (currentLineIndex < linesForState.Count - 1 || currentNode.loopThroughLines) { return true; } } } - // For other node types, use the standard check - else if (currentNode.dialogueLines.Count > 0) + // For other node types, check for DialogueContent first, then fall back to legacy text + else { - // If we're not at the end of the lines or we loop through them - if (currentLineIndex < currentNode.dialogueLines.Count - 1 || currentNode.loopThroughLines) + // Check for DialogueContent + if (currentNode.dialogueContent != null && currentNode.dialogueContent.Count > 0) { - return true; + if (currentLineIndex < currentNode.dialogueContent.Count - 1 || currentNode.loopThroughLines) + { + return true; + } + + // If we're at the end of content but not waiting for a condition and have a next node + if (!IsWaitingForCondition() && !string.IsNullOrEmpty(currentNode.nextNodeID)) + { + RuntimeDialogueNode nextNode = dialogueGraph.GetNodeByID(currentNode.nextNodeID); + return nextNode != null && + ((nextNode.dialogueContent != null && nextNode.dialogueContent.Count > 0) || + (nextNode.dialogueLines != null && nextNode.dialogueLines.Count > 0) || + nextNode.nodeType != RuntimeDialogueNodeType.End); + } } - // If we're at the end of lines but not waiting for a condition and have a next node - if (!IsWaitingForCondition() && !string.IsNullOrEmpty(currentNode.nextNodeID)) + // Fall back to legacy text lines + if (currentNode.dialogueLines != null && currentNode.dialogueLines.Count > 0) { - // We need to check if the next node would have lines - RuntimeDialogueNode nextNode = dialogueGraph.GetNodeByID(currentNode.nextNodeID); - return nextNode != null && (nextNode.dialogueLines.Count > 0 || nextNode.nodeType != RuntimeDialogueNodeType.End); + if (currentLineIndex < currentNode.dialogueLines.Count - 1 || currentNode.loopThroughLines) + { + return true; + } + + // If we're at the end of lines but not waiting for a condition and have a next node + if (!IsWaitingForCondition() && !string.IsNullOrEmpty(currentNode.nextNodeID)) + { + RuntimeDialogueNode nextNode = dialogueGraph.GetNodeByID(currentNode.nextNodeID); + return nextNode != null && + ((nextNode.dialogueContent != null && nextNode.dialogueContent.Count > 0) || + (nextNode.dialogueLines != null && nextNode.dialogueLines.Count > 0) || + nextNode.nodeType != RuntimeDialogueNodeType.End); + } } } - return false; } diff --git a/Assets/Scripts/Dialogue/DialogueContent.cs b/Assets/Scripts/Dialogue/DialogueContent.cs new file mode 100644 index 00000000..7adfb2af --- /dev/null +++ b/Assets/Scripts/Dialogue/DialogueContent.cs @@ -0,0 +1,76 @@ +using System; +using UnityEngine; + +namespace Dialogue +{ + /// + /// Content type for dialogue entries + /// + public enum DialogueContentType + { + Text, + Image + } + + /// + /// Wrapper class for dialogue content that can be either text or image + /// + [Serializable] + public class DialogueContent + { + [SerializeField] private DialogueContentType _contentType = DialogueContentType.Text; + [SerializeField] private string _text = string.Empty; + [SerializeField] private Sprite _image = null; + + /// + /// The type of content this entry contains + /// + public DialogueContentType ContentType => _contentType; + + /// + /// The text content (valid when ContentType is Text) + /// + public string Text => _text; + + /// + /// The image content (valid when ContentType is Image) + /// + public Sprite Image => _image; + + /// + /// Create text content + /// + /// The text to display + public static DialogueContent CreateText(string text) + { + return new DialogueContent + { + _contentType = DialogueContentType.Text, + _text = text + }; + } + + /// + /// Create image content + /// + /// The image to display + public static DialogueContent CreateImage(Sprite image) + { + return new DialogueContent + { + _contentType = DialogueContentType.Image, + _image = image + }; + } + + /// + /// Returns a string representation of this content + /// + public override string ToString() + { + return ContentType == DialogueContentType.Text + ? $"Text: {_text}" + : $"Image: {_image?.name ?? "None"}"; + } + } +} diff --git a/Assets/Scripts/Dialogue/DialogueContent.cs.meta b/Assets/Scripts/Dialogue/DialogueContent.cs.meta new file mode 100644 index 00000000..196f40bb --- /dev/null +++ b/Assets/Scripts/Dialogue/DialogueContent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6b479dc736d44dea83d4d2cf4d940d8b +timeCreated: 1759912630 \ No newline at end of file diff --git a/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs b/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs index 51a1cdf2..d08c271b 100644 --- a/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs +++ b/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs @@ -36,10 +36,14 @@ namespace Dialogue public RuntimeDialogueNodeType nodeType; public string nextNodeID; - // Basic dialogue + // Basic dialogue - legacy text-only field + [HideInInspector] public List dialogueLines = new List(); public bool loopThroughLines; + // New mixed content field that supports both text and images + public List dialogueContent = new List(); + // Conditional nodes public string puzzleStepID; // For WaitOnPuzzleStep public string pickupItemID; // For WaitOnPickup @@ -47,9 +51,14 @@ namespace Dialogue public string combinationResultItemID; // For WaitOnCombination // For WaitOnSlot - different responses + [HideInInspector] public List incorrectItemLines = new List(); public bool loopThroughIncorrectLines; + public List incorrectItemContent = new List(); + + [HideInInspector] public List forbiddenItemLines = new List(); public bool loopThroughForbiddenLines; + public List forbiddenItemContent = new List(); } } \ No newline at end of file diff --git a/Assets/Scripts/Dialogue/SpeechBubble.cs b/Assets/Scripts/Dialogue/SpeechBubble.cs index 886e802a..c86878bc 100644 --- a/Assets/Scripts/Dialogue/SpeechBubble.cs +++ b/Assets/Scripts/Dialogue/SpeechBubble.cs @@ -2,6 +2,7 @@ using System.Collections; using TMPro; using UnityEngine; +using UnityEngine.UI; namespace Dialogue { @@ -18,6 +19,7 @@ namespace Dialogue public class SpeechBubble : MonoBehaviour { [SerializeField] private TextMeshProUGUI textDisplay; + [SerializeField] private Image imageDisplay; // New field for displaying images [SerializeField] private TextDisplayMode displayMode = TextDisplayMode.Typewriter; [SerializeField] private float typewriterSpeed = 0.05f; // Time between characters in seconds [SerializeField] private AudioSource typingSoundSource; @@ -29,11 +31,18 @@ namespace Dialogue private Coroutine typewriterCoroutine; private Coroutine promptUpdateCoroutine; private string currentFullText = string.Empty; + private Sprite currentImage = null; private bool isVisible = false; + private DialogueContentType currentContentType = DialogueContentType.Text; private void Awake() { - + // Ensure we have both components + if (textDisplay == null) + Debug.LogError("SpeechBubble: TextMeshProUGUI component is not assigned!"); + + if (imageDisplay == null) + Debug.LogError("SpeechBubble: Image component is not assigned!"); } /// @@ -92,6 +101,7 @@ namespace Dialogue } currentFullText = text; + currentContentType = DialogueContentType.Text; // Stop any existing typewriter effect if (typewriterCoroutine != null) @@ -100,6 +110,13 @@ namespace Dialogue typewriterCoroutine = null; } + // Activate text display, deactivate image display + textDisplay.gameObject.SetActive(true); + if (imageDisplay != null) + { + imageDisplay.gameObject.SetActive(false); + } + // Display text based on the selected mode if (displayMode == TextDisplayMode.Instant) { @@ -259,5 +276,117 @@ namespace Dialogue typewriterCoroutine = null; } + + /// + /// Set the image to display in the speech bubble + /// + /// Sprite to display + public void SetImage(Sprite sprite) + { + if (imageDisplay == null) + { + Debug.LogError("SpeechBubble: Image component is not assigned!"); + return; + } + + currentImage = sprite; + currentContentType = DialogueContentType.Image; + + // Activate image display, set the sprite + imageDisplay.gameObject.SetActive(true); + imageDisplay.sprite = sprite; + + // Deactivate text display + if (textDisplay != null) + { + textDisplay.gameObject.SetActive(false); + } + + // Make sure the bubble is visible when setting image + if (!isVisible) + Show(); + } + + /// + /// Clear the displayed image + /// + public void ClearImage() + { + SetImage(null); + } + + /// + /// Set the content of the speech bubble (text or image) + /// + /// Text content + /// Image content + public void SetContent(string text, Sprite image) + { + if (!string.IsNullOrEmpty(text)) + { + currentContentType = DialogueContentType.Text; + SetText(text); + } + else if (image != null) + { + currentContentType = DialogueContentType.Image; + SetImage(image); + } + } + + /// + /// Get the current content type of the speech bubble + /// + /// Current content type + public DialogueContentType GetCurrentContentType() + { + return currentContentType; + } + + /// + /// Display dialogue content (text or image) + /// + /// The dialogue content to display + /// Whether there are more dialogue content items available + public void DisplayDialogueContent(DialogueContent content, bool hasMoreDialogue) + { + // Cancel any existing prompt update + if (promptUpdateCoroutine != null) + { + StopCoroutine(promptUpdateCoroutine); + promptUpdateCoroutine = null; + } + + if (content == null) + { + UpdatePromptVisibility(hasMoreDialogue); + return; + } + + // Display the content based on its type + currentContentType = content.ContentType; + + if (content.ContentType == DialogueContentType.Text) + { + // Show text display, hide image display + textDisplay.gameObject.SetActive(true); + if (imageDisplay != null) imageDisplay.gameObject.SetActive(false); + + // Display the text + DisplayDialogueLine(content.Text, hasMoreDialogue); + } + else // Image content + { + // Hide text display, show image display + textDisplay.gameObject.SetActive(false); + if (imageDisplay != null) imageDisplay.gameObject.SetActive(true); + + // Set the image + SetImage(content.Image); + + // After a delay, update the prompt visibility + promptUpdateCoroutine = StartCoroutine(UpdatePromptAfterDelay(hasMoreDialogue)); + } + } } } diff --git a/Assets/Scripts/Dialogue/SpeechBubbleController.cs b/Assets/Scripts/Dialogue/SpeechBubbleController.cs deleted file mode 100644 index e02abfc9..00000000 --- a/Assets/Scripts/Dialogue/SpeechBubbleController.cs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Assets/Scripts/Dialogue/SpeechBubbleController.cs.meta b/Assets/Scripts/Dialogue/SpeechBubbleController.cs.meta deleted file mode 100644 index fdd11866..00000000 --- a/Assets/Scripts/Dialogue/SpeechBubbleController.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 877344c7a0014922bc3a2a469e03792d -timeCreated: 1759050622 \ No newline at end of file -- 2.49.1 From 5ad3ae8815ede711f138b35ac060e7bd73516b37 Mon Sep 17 00:00:00 2001 From: Michal Pikulski Date: Wed, 8 Oct 2025 11:27:27 +0200 Subject: [PATCH 2/3] Working dialogue images mixed with text --- .../Anne Lise/AnaLiseDialogue.dialoguegraph | 76 +++-- .../GardenerDialogueGraph.dialoguegraph | 30 +- Assets/Dialogue/TestAssDialogue.dialoguegraph | 208 ++++++++------ Assets/Dialogue/TestDialogue.dialoguegraph | 269 +++++++----------- .../Editor/Dialogue/DialogueGraphImporter.cs | 100 +++++-- Assets/Editor/Dialogue/DialogueNodes.cs | 65 +++-- .../Scenes/Levels/AppleHillsOverworld.unity | 14 +- Assets/Scripts/Dialogue/DialogueComponent.cs | 57 +++- Assets/Scripts/UI/PauseMenu.cs | 29 ++ 9 files changed, 485 insertions(+), 363 deletions(-) diff --git a/Assets/Dialogue/Anne Lise/AnaLiseDialogue.dialoguegraph b/Assets/Dialogue/Anne Lise/AnaLiseDialogue.dialoguegraph index 7245df8e..34d6c121 100644 --- a/Assets/Dialogue/Anne Lise/AnaLiseDialogue.dialoguegraph +++ b/Assets/Dialogue/Anne Lise/AnaLiseDialogue.dialoguegraph @@ -40,14 +40,14 @@ MonoBehaviour: - __option_DialogueLineType - __option_NoLines - RequiredPuzzleStep - - DefaultDialogueLine - LoopThroughDefaultLines + - DefaultDialogueContent m_ValueList: - rid: 4008004731853340754 - rid: 4008004731853340755 - rid: 4008004731853340756 - - rid: 4008004731853340757 - rid: 4008004731853340758 + - rid: 7545629632211976319 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -82,10 +82,6 @@ MonoBehaviour: type: {class: 'Constant`1[[PuzzleStepSO, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: {fileID: 11400000, guid: ea383d1dee861f54c9a1d4f32a2f6afc, type: 2} - - rid: 4008004731853340757 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: That Lawnmower is out of control! - rid: 4008004731853340758 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: @@ -125,6 +121,41 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in + - rid: 7545629632211976315 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} + - rid: 7545629632211976316 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} + - rid: 7545629632211976317 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} + - rid: 7545629632211976318 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} + - rid: 7545629632211976319 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} - rid: 7772910664224079872 type: {class: GraphModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -351,17 +382,17 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine2 - LoopThroughDefaultLines - - DefaultDialogueLine1 - - DefaultDialogueLine3 + - DefaultDialogueContent1 + - DefaultDialogueContent2 + - DefaultDialogueContent3 m_ValueList: - rid: 7772910664224079887 - rid: 7772910664224079888 - - rid: 7772910664224079894 - rid: 7772910664224079890 - - rid: 7772910664224079893 - - rid: 7772910664224079895 + - rid: 7545629632211976315 + - rid: 7545629632211976316 + - rid: 7545629632211976317 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -431,19 +462,6 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in - - rid: 7772910664224079893 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Ok Guys! Let's get these birds out in the open! - - rid: 7772910664224079894 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Place things the Birds might like in their nests. - - rid: 7772910664224079895 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: I guess what you find in th enests can give you a clue of what they - like? - rid: 7772910664224079896 type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -464,13 +482,13 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine - LoopThroughDefaultLines + - DefaultDialogueContent m_ValueList: - rid: 7772910664224079897 - rid: 7772910664224079898 - - rid: 7772910664224079899 - rid: 7772910664224079900 + - rid: 7545629632211976318 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -501,10 +519,6 @@ MonoBehaviour: type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: 1 - - rid: 7772910664224079899 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Go on, get them out of their hiding spots. - rid: 7772910664224079900 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: diff --git a/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph b/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph index 95318000..e2a3ba17 100644 --- a/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph +++ b/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph @@ -19,6 +19,20 @@ MonoBehaviour: RefIds: - rid: -2 type: {class: , ns: , asm: } + - rid: 7545629632211976320 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} + - rid: 7545629632211976321 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: + _image: {fileID: 0} - rid: 7772910664224079994 type: {class: GraphModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -296,15 +310,15 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine2 - LoopThroughDefaultLines - - DefaultDialogueLine1 + - DefaultDialogueContent1 + - DefaultDialogueContent2 m_ValueList: - rid: 7772910664224080006 - rid: 7772910664224080007 - - rid: 7772910664224080012 - rid: 7772910664224080009 - - rid: 7772910664224080011 + - rid: 7545629632211976320 + - rid: 7545629632211976321 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -374,14 +388,6 @@ MonoBehaviour: - rid: 7772910664224080010 type: {class: DialogueNode, ns: Editor.Dialogue, asm: AppleHillsEditor} data: - - rid: 7772910664224080011 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: My lawnmower is on a break so i'm also on a break... - - rid: 7772910664224080012 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: I ain't moving until she decides to move... - rid: 7772910664224080013 type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: diff --git a/Assets/Dialogue/TestAssDialogue.dialoguegraph b/Assets/Dialogue/TestAssDialogue.dialoguegraph index 923a5343..6a213760 100644 --- a/Assets/Dialogue/TestAssDialogue.dialoguegraph +++ b/Assets/Dialogue/TestAssDialogue.dialoguegraph @@ -58,10 +58,10 @@ MonoBehaviour: m_LocalSubgraphs: [] m_LastKnownBounds: serializedVersion: 2 - x: 115 - y: 7 - width: 3353 - height: 399 + x: -36 + y: 12 + width: 3787.2 + height: 559.19995 m_GraphElementMetaData: - m_Guid: m_Value0: 15250916379536742066 @@ -237,7 +237,7 @@ MonoBehaviour: serializedVersion: 2 Hash: b25679f5a423a6d30df98cd989cabcf0 m_Version: 2 - m_Position: {x: 303.87872, y: 210.33638} + m_Position: {x: 152.62463, y: 208.7273} m_Title: m_Tooltip: m_NodePreviewModel: @@ -280,7 +280,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 4c15a501ab0b3876663348bd143a160c m_Version: 2 - m_Position: {x: 115.3345, y: 263.23343} + m_Position: {x: -35.919586, y: 261.62433} m_Title: SpeakerName m_Tooltip: m_NodePreviewModel: @@ -376,7 +376,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 63e5eb3c34667babc753a8b79a9a6d99 m_Version: 2 - m_Position: {x: 513.6555, y: 168.80977} + m_Position: {x: 362.40143, y: 167.20068} m_Title: m_Tooltip: m_NodePreviewModel: @@ -386,13 +386,13 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine - LoopThroughDefaultLines + - DefaultDialogueContent m_ValueList: - rid: 1226592702090707077 - rid: 1226592702090707078 - - rid: 1226592702090707079 - rid: 1226592702090707080 + - rid: 7545629632211976303 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -423,10 +423,6 @@ MonoBehaviour: type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: 1 - - rid: 1226592702090707079 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Psst boy... Why don't you pick up THAT ASS over there? - rid: 1226592702090707080 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: @@ -476,7 +472,7 @@ MonoBehaviour: serializedVersion: 2 Hash: d897c8a6890a4ec4f5f614a0a23bfb0b m_Version: 2 - m_Position: {x: 906.1956, y: 144.21957} + m_Position: {x: 832.17773, y: 142.61052} m_Title: m_Tooltip: m_NodePreviewModel: @@ -487,18 +483,18 @@ MonoBehaviour: - __option_DialogueLineType - __option_NoLines - RequiredPickup - - DefaultDialogueLine2 - LoopThroughDefaultLines - - DefaultDialogueLine1 - - DefaultDialogueLine3 + - DefaultDialogueContent1 + - DefaultDialogueContent2 + - DefaultDialogueContent3 m_ValueList: - rid: 1226592702090707084 - rid: 1226592702090707085 - rid: 1226592702090707086 - - rid: 1226592702090707092 - rid: 1226592702090707088 - - rid: 1226592702090707091 - - rid: 1226592702090707093 + - rid: 7545629632211976304 + - rid: 7545629632211976305 + - rid: 7545629632211976306 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -572,18 +568,6 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in - - rid: 1226592702090707091 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: I said pick it up! - - rid: 1226592702090707092 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Cmon, don't be like this! - - rid: 1226592702090707093 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: The ass is waiting there for you! - rid: 1226592702090707099 type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -594,7 +578,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 3b750432bd23177050f4f1fac360a6c3 m_Version: 2 - m_Position: {x: 1376.4679, y: 141.66953} + m_Position: {x: 1300.841, y: 141.66953} m_Title: DialogueNode m_Tooltip: m_NodePreviewModel: @@ -605,14 +589,14 @@ MonoBehaviour: - __option_DialogueLineType - __option_NoLines - LoopThroughDefaultLines - - DefaultDialogueLine1 - - DefaultDialogueLine2 + - DefaultDialogueContent1 + - DefaultDialogueContent2 m_ValueList: - rid: 1226592702090707100 - rid: 1226592702090707101 - rid: 1226592702090707103 - - rid: 1226592702090707106 - - rid: 1226592702090707107 + - rid: 7545629632211976307 + - rid: 7545629632211976308 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -682,14 +666,6 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in - - rid: 1226592702090707106 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Ohhhh yeah, that's the stuff. - - rid: 1226592702090707107 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Now, go on, chop it! - rid: 1226592736610877523 type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -700,7 +676,7 @@ MonoBehaviour: serializedVersion: 2 Hash: f3e06bfaeec3029fe7bcecfcb7e96ae8 m_Version: 2 - m_Position: {x: 1763.6455, y: 116.19321} + m_Position: {x: 1771.6909, y: 116.19321} m_Title: m_Tooltip: m_NodePreviewModel: @@ -711,14 +687,14 @@ MonoBehaviour: - __option_DialogueLineType - __option_NoLines - RequiredResultItem - - DefaultDialogueLine - LoopThroughDefaultLines + - DefaultDialogueContent m_ValueList: - rid: 1226592736610877524 - rid: 1226592736610877525 - rid: 1226592736610877526 - - rid: 1226592736610877527 - rid: 1226592736610877528 + - rid: 7545629632211976309 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -753,14 +729,10 @@ MonoBehaviour: type: {class: 'Constant`1[[PickupItemData, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: {fileID: 11400000, guid: ecae2d83a5ab2a047a2733ebff607380, type: 2} - - rid: 1226592736610877527 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: I need my meat :( - rid: 1226592736610877528 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 1 + m_Value: 0 - rid: 1226592736610877529 type: {class: WaitOnCombination, ns: Editor.Dialogue, asm: AppleHillsEditor} data: @@ -817,12 +789,12 @@ MonoBehaviour: - __option_DialogueLineType - __option_NoLines - LoopThroughDefaultLines - - DefaultDialogueLine + - DefaultDialogueContent m_ValueList: - rid: 1226592736610877538 - rid: 1226592736610877539 - rid: 1226592736610877540 - - rid: 1226592736610877545 + - rid: 7545629632211976310 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -892,10 +864,6 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in - - rid: 1226592736610877545 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Nice, that's the stuff! Now go cook it for me! - rid: 1226592736610877546 type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -906,7 +874,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 69712d8f46502fa577433f59c2c1f85c m_Version: 2 - m_Position: {x: 2650.1987, y: 6.86882} + m_Position: {x: 2752.9822, y: 11.763229} m_Title: m_Tooltip: m_NodePreviewModel: @@ -921,12 +889,12 @@ MonoBehaviour: - __option_ForbiddenItemDialogueLineType - __option_ForbiddenItemNoLines - RequiredSlot - - DefaultDialogueLine - LoopThroughDefaultLines - - IncorrectItemDialogueLine - LoopThroughIncorrectItemLines - - ForbiddenItemDialogueLine - LoopThroughForbiddenItemLines + - DefaultDialogueContent + - IncorrectItemDialogueContent + - ForbiddenItemDialogueContent m_ValueList: - rid: 1226592736610877547 - rid: 1226592736610877548 @@ -935,12 +903,12 @@ MonoBehaviour: - rid: 1226592736610877551 - rid: 1226592736610877552 - rid: 1226592736610877553 - - rid: 1226592736610877554 - rid: 1226592736610877555 - - rid: 1226592736610877556 - rid: 1226592736610877557 - - rid: 1226592736610877558 - rid: 1226592736610877559 + - rid: 7545629632211976311 + - rid: 7545629632211976312 + - rid: 7545629632211976313 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1005,30 +973,18 @@ MonoBehaviour: type: {class: 'Constant`1[[PickupItemData, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: {fileID: 11400000, guid: e0fad48a84a6b6346ac17c84bc512500, type: 2} - - rid: 1226592736610877554 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Cmon, it's not gonna cook itself! - rid: 1226592736610877555 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: 1 - - rid: 1226592736610877556 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: What do you think you're cooking?! - rid: 1226592736610877557 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: 1 - - rid: 1226592736610877558 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: - rid: 1226592736610877559 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 0 + m_Value: 1 - rid: 1226592736610877560 type: {class: WaitOnSlot, ns: Editor.Dialogue, asm: AppleHillsEditor} data: @@ -1074,7 +1030,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 91bec6fb97b9d7d954d9847f1c7dfdce m_Version: 2 - m_Position: {x: 3164.9407, y: 88.21074} + m_Position: {x: 3317.6943, y: 96.60597} m_Title: DialogueNode m_Tooltip: m_NodePreviewModel: @@ -1085,12 +1041,12 @@ MonoBehaviour: - __option_DialogueLineType - __option_NoLines - LoopThroughDefaultLines - - DefaultDialogueLine + - DefaultDialogueContent m_ValueList: - rid: 1226592736610877568 - rid: 1226592736610877569 - rid: 1226592736610877570 - - rid: 1226592736610877571 + - rid: 7545629632211976314 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1125,10 +1081,6 @@ MonoBehaviour: type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: 0 - - rid: 1226592736610877571 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Sweat, delicions steak! - rid: 1226592736610877572 type: {class: DialogueNode, ns: Editor.Dialogue, asm: AppleHillsEditor} data: @@ -1164,3 +1116,87 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in + - rid: 7545629632211976303 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Hey boy, go on and pick up that ass over there! + _image: {fileID: 0} + - rid: 7545629632211976304 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: "Go on, it's right there!\t\t" + _image: {fileID: 0} + - rid: 7545629632211976305 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: I need ASS! + _image: {fileID: 0} + - rid: 7545629632211976306 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: C'mon, don't be like this! + _image: {fileID: 0} + - rid: 7545629632211976307 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Yessss, that's the stuff, now chop it! + _image: {fileID: 0} + - rid: 7545629632211976308 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 1 + _text: + _image: {fileID: 6282751622250221668, guid: 204325ac88be74d4d882a078c64cf5e1, type: 3} + - rid: 7545629632211976309 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Chop it!! + _image: {fileID: 0} + - rid: 7545629632211976310 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Good, shit now cook! + _image: {fileID: 0} + - rid: 7545629632211976311 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 1 + _text: + _image: {fileID: 6282751622250221668, guid: 204325ac88be74d4d882a078c64cf5e1, type: 3} + - rid: 7545629632211976312 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: What exactly are you cooking?! + _image: {fileID: 0} + - rid: 7545629632211976313 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: What exactly are you cooking?! + _image: {fileID: 0} + - rid: 7545629632211976314 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Yessssss, thanks! + _image: {fileID: 0} diff --git a/Assets/Dialogue/TestDialogue.dialoguegraph b/Assets/Dialogue/TestDialogue.dialoguegraph index d19ef314..d6f55615 100644 --- a/Assets/Dialogue/TestDialogue.dialoguegraph +++ b/Assets/Dialogue/TestDialogue.dialoguegraph @@ -36,14 +36,12 @@ MonoBehaviour: - rid: 1219994508087787764 - rid: 1219994508087787770 - rid: 1219994508087787776 - - rid: 1226592702090706949 m_GraphWireModels: - rid: 1219994508087787755 - rid: 1219994508087787773 - rid: 1219994508087787779 - rid: 1219994508087787813 - - rid: 1226592702090706955 - - rid: 1226592702090706956 + - rid: 7545629632211976322 m_GraphStickyNoteModels: [] m_GraphPlacematModels: [] m_GraphVariableModels: @@ -54,10 +52,10 @@ MonoBehaviour: m_LocalSubgraphs: [] m_LastKnownBounds: serializedVersion: 2 - x: 128 - y: -65 - width: 2055 - height: 243 + x: -163.2 + y: -62.4 + width: 2048.8 + height: 514.4 m_GraphElementMetaData: - m_Guid: m_Value0: 13346176596883742728 @@ -148,29 +146,13 @@ MonoBehaviour: m_Category: 2 m_Index: 3 - m_Guid: - m_Value0: 3534792673092891566 - m_Value1: 6472493350207860515 + m_Value0: 3747411033454993788 + m_Value1: 16062730125593257019 m_HashGuid: serializedVersion: 2 - Hash: aef35a42351b0e3123af37c668ead259 - m_Category: 0 - m_Index: 6 - - m_Guid: - m_Value0: 1069232297653548642 - m_Value1: 12871763382231758094 - m_HashGuid: - serializedVersion: 2 - Hash: 62b603141cadd60e0ef5cd3e99b0a1b2 + Hash: 7ce176f47a7a01343ba4f3faf147eade m_Category: 2 m_Index: 4 - - m_Guid: - m_Value0: 6652862542851746443 - m_Value1: 1010545699289270970 - m_HashGuid: - serializedVersion: 2 - Hash: 8b2a2efe3bb7535cba8a6f9bf52d060e - m_Category: 2 - m_Index: 5 m_EntryPoint: rid: 1219994508087787747 m_Graph: @@ -201,7 +183,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 0820e35ee72437b996f6e8e25ecef5fa m_Version: 2 - m_Position: {x: 316.4595, y: -65.01193} + m_Position: {x: 6.237854, y: -6.821892} m_Title: m_Tooltip: m_NodePreviewModel: @@ -240,7 +222,7 @@ MonoBehaviour: serializedVersion: 2 Hash: be46cc430316f2042ae9853a1220f241 m_Version: 2 - m_Position: {x: 2070.2, y: 1.3479004} + m_Position: {x: 1771.3995, y: -14.25327} m_Title: m_Tooltip: m_NodePreviewModel: @@ -277,7 +259,7 @@ MonoBehaviour: serializedVersion: 2 Hash: e77ae5c2cfec4277e8e3c20e1d1da05f m_Version: 2 - m_Position: {x: 530.97986, y: -60.683594} + m_Position: {x: 220.75827, y: -61.741615} m_Title: m_Tooltip: m_NodePreviewModel: @@ -287,13 +269,15 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine - LoopThroughDefaultLines + - DefaultDialogueContent1 + - DefaultDialogueContent2 m_ValueList: - rid: 1219994508087787857 - rid: 1219994508087787858 - - rid: 1219994508087787897 - rid: 1219994508087787904 + - rid: 7545629632211976301 + - rid: 7545629632211976302 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -381,7 +365,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 85d948457f20a43a3e0d65b11e3e1a96 m_Version: 2 - m_Position: {x: 128.085, y: -12.860001} + m_Position: {x: -163.09268, y: 58.026043} m_Title: Anna-Lyse m_Tooltip: m_NodePreviewModel: @@ -422,7 +406,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 3cbfd8ef332fa01b78a5ecc384f2e5e7 m_Version: 2 - m_Position: {x: 914.5827, y: -60.08837} + m_Position: {x: 714.5492, y: -62.216354} m_Title: DialogueNode m_Tooltip: m_NodePreviewModel: @@ -432,17 +416,17 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine1 - - DefaultDialogueLine2 - - DefaultDialogueLine3 - LoopThroughDefaultLines + - DefaultDialogueContent1 + - DefaultDialogueContent2 + - DefaultDialogueContent3 m_ValueList: - rid: 1219994508087787860 - rid: 1219994508087787861 - - rid: 1219994508087787900 - - rid: 1219994508087787901 - - rid: 1219994508087787902 - rid: 1219994508087787905 + - rid: 7545629632211976294 + - rid: 7545629632211976295 + - rid: 7545629632211976296 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -503,7 +487,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 05c5ff0463a83c928482c30dbf7a2c0b m_Version: 2 - m_Position: {x: 1294.008, y: -60.75061} + m_Position: {x: 1210.0558, y: -60.75061} m_Title: DialogueNode m_Tooltip: m_NodePreviewModel: @@ -513,13 +497,19 @@ MonoBehaviour: m_KeyList: - __option_DialogueLineType - __option_NoLines - - DefaultDialogueLine - LoopThroughDefaultLines + - DefaultDialogueContent1 + - DefaultDialogueContent2 + - DefaultDialogueContent3 + - DefaultDialogueContent4 m_ValueList: - rid: 1219994508087787863 - rid: 1219994508087787864 - - rid: 1219994508087787898 - rid: 1219994508087787906 + - rid: 7545629632211976297 + - rid: 7545629632211976298 + - rid: 7545629632211976323 + - rid: 7545629632211976324 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -609,14 +599,14 @@ MonoBehaviour: m_EnumType: m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - m_Value: 0 + m_Value: 1 m_EnumType: m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - rid: 1219994508087787858 type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 1 + m_Value: 2 - rid: 1219994508087787860 type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: @@ -639,34 +629,14 @@ MonoBehaviour: m_EnumType: m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - m_Value: 0 + m_Value: 1 m_EnumType: m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - rid: 1219994508087787864 type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 1 - - rid: 1219994508087787897 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: This is a first line of dialogue - - rid: 1219994508087787898 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Another regular line - - rid: 1219994508087787900 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: One multiline - - rid: 1219994508087787901 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Two multiline - - rid: 1219994508087787902 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Value: Three multiline + m_Value: 4 - rid: 1219994508087787904 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: @@ -678,82 +648,65 @@ MonoBehaviour: - rid: 1219994508087787906 type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 0 - - rid: 1226592702090706949 - type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} - data: - m_Guid: - m_Value0: 3534792673092891566 - m_Value1: 6472493350207860515 - m_HashGuid: - serializedVersion: 2 - Hash: aef35a42351b0e3123af37c668ead259 - m_Version: 2 - m_Position: {x: 1675.55, y: -47.149998} - m_Title: DialogueNode - m_Tooltip: - m_NodePreviewModel: - rid: -2 - m_State: 0 - m_InputConstantsById: - m_KeyList: - - __option_DialogueLineType - - __option_NoLines - - DefaultDialogueLine2 - - LoopThroughDefaultLines - - DefaultDialogueLine1 - m_ValueList: - - rid: 1226592702090706950 - - rid: 1226592702090706951 - - rid: 1226592702090706958 - - rid: 1226592702090706953 - - rid: 1226592702090706957 - m_InputPortInfos: - expandedPortsById: - m_KeyList: [] - m_ValueList: - m_OutputPortInfos: - expandedPortsById: - m_KeyList: [] - m_ValueList: - m_Collapsed: 0 - m_CurrentModeIndex: 0 - m_ElementColor: - m_Color: {r: 0, g: 0, b: 0, a: 0} - m_HasUserColor: 0 - m_Node: - rid: 1226592702090706954 - - rid: 1226592702090706950 - type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + m_Value: 1 + - rid: 7545629632211976294 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: - m_EnumType: - m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null - m_Value: 1 - m_EnumType: - m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null - - rid: 1226592702090706951 - type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + _contentType: 0 + _text: Some other test + _image: {fileID: 0} + - rid: 7545629632211976295 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 2 - - rid: 1226592702090706953 - type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + m_Value: + _contentType: 0 + _text: Some much longer text in here etc. + _image: {fileID: 0} + - rid: 7545629632211976296 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: 1 - - rid: 1226592702090706954 - type: {class: DialogueNode, ns: Editor.Dialogue, asm: AppleHillsEditor} - data: - - rid: 1226592702090706955 + m_Value: + _contentType: 0 + _text: Some oooother text + _image: {fileID: 0} + - rid: 7545629632211976297 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 1 + _text: + _image: {fileID: -765527507412255412, guid: f70246e6148769846aaea223ec0c2a55, type: 3} + - rid: 7545629632211976298 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Now it's text + _image: {fileID: -9213056636207805707, guid: 00354ded9d8f8d643acc14837a229544, type: 3} + - rid: 7545629632211976301 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 0 + _text: Psst, I'm just testing some stuff df + _image: {fileID: 0} + - rid: 7545629632211976302 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + _contentType: 1 + _text: + _image: {fileID: -9213056636207805707, guid: 00354ded9d8f8d643acc14837a229544, type: 3} + - rid: 7545629632211976322 type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Guid: - m_Value0: 1069232297653548642 - m_Value1: 12871763382231758094 + m_Value0: 3747411033454993788 + m_Value1: 16062730125593257019 m_HashGuid: serializedVersion: 2 - Hash: 62b603141cadd60e0ef5cd3e99b0a1b2 + Hash: 7ce176f47a7a01343ba4f3faf147eade m_Version: 2 m_FromPortReference: m_NodeModelGuid: @@ -766,38 +719,6 @@ MonoBehaviour: m_PortDirection: 2 m_PortOrientation: 0 m_Title: out - m_ToPortReference: - m_NodeModelGuid: - m_Value0: 3534792673092891566 - m_Value1: 6472493350207860515 - m_NodeModelHashGuid: - serializedVersion: 2 - Hash: aef35a42351b0e3123af37c668ead259 - m_UniqueId: in - m_PortDirection: 1 - m_PortOrientation: 0 - m_Title: in - - rid: 1226592702090706956 - type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} - data: - m_Guid: - m_Value0: 6652862542851746443 - m_Value1: 1010545699289270970 - m_HashGuid: - serializedVersion: 2 - Hash: 8b2a2efe3bb7535cba8a6f9bf52d060e - m_Version: 2 - m_FromPortReference: - m_NodeModelGuid: - m_Value0: 3534792673092891566 - m_Value1: 6472493350207860515 - m_NodeModelHashGuid: - serializedVersion: 2 - Hash: aef35a42351b0e3123af37c668ead259 - m_UniqueId: out - m_PortDirection: 2 - m_PortOrientation: 0 - m_Title: out m_ToPortReference: m_NodeModelGuid: m_Value0: 356371523793864382 @@ -809,11 +730,17 @@ MonoBehaviour: m_PortDirection: 1 m_PortOrientation: 0 m_Title: in - - rid: 1226592702090706957 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + - rid: 7545629632211976323 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: And we're... - - rid: 1226592702090706958 - type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + m_Value: + _contentType: 1 + _text: + _image: {fileID: -9213056636207805707, guid: 00354ded9d8f8d643acc14837a229544, type: 3} + - rid: 7545629632211976324 + type: {class: 'Constant`1[[Dialogue.DialogueContent, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: ...in a loop + m_Value: + _contentType: 0 + _text: Now it's text again and it should loop! + _image: {fileID: -9213056636207805707, guid: 00354ded9d8f8d643acc14837a229544, type: 3} diff --git a/Assets/Editor/Dialogue/DialogueGraphImporter.cs b/Assets/Editor/Dialogue/DialogueGraphImporter.cs index 9255a306..3556912c 100644 --- a/Assets/Editor/Dialogue/DialogueGraphImporter.cs +++ b/Assets/Editor/Dialogue/DialogueGraphImporter.cs @@ -111,24 +111,42 @@ namespace Editor.Dialogue var lineCountOption = node.GetNodeOptionByName("NoLines"); lineCountOption.TryGetValue(out var lineCount); - // Process dialogue lines based on line type + // Process dialogue content if (lineType == DialogueType.SayMultipleLines) { for (var i = 0; i < lineCount; i++) { - var lineValue = GetPortValue(node.GetInputPortByName($"DefaultDialogueLine{i + 1}")); - if (!string.IsNullOrEmpty(lineValue)) + var contentPort = node.GetInputPortByName($"DefaultDialogueContent{i + 1}"); + var contentValue = GetPortValue(contentPort); + + if (contentValue != null) { - runtimeNode.dialogueLines.Add(lineValue); + // Add to dialogueContent list + runtimeNode.dialogueContent.Add(contentValue); + + // Also add to legacy dialogueLines list for backward compatibility + if (contentValue.ContentType == DialogueContentType.Text && !string.IsNullOrEmpty(contentValue.Text)) + { + runtimeNode.dialogueLines.Add(contentValue.Text); + } } } } else { - var lineValue = GetPortValue(node.GetInputPortByName("DefaultDialogueLine")); - if (!string.IsNullOrEmpty(lineValue)) + var contentPort = node.GetInputPortByName("DefaultDialogueContent"); + var contentValue = GetPortValue(contentPort); + + if (contentValue != null) { - runtimeNode.dialogueLines.Add(lineValue); + // Add to dialogueContent list + runtimeNode.dialogueContent.Add(contentValue); + + // Also add to legacy dialogueLines list for backward compatibility + if (contentValue.ContentType == DialogueContentType.Text && !string.IsNullOrEmpty(contentValue.Text)) + { + runtimeNode.dialogueLines.Add(contentValue.Text); + } } } @@ -169,60 +187,98 @@ namespace Editor.Dialogue runtimeNode.slotItemID = slot.itemId; } - // Process incorrect item lines + // Get line type and count options for incorrect items var incorrectItemLineTypeOption = node.GetNodeOptionByName("IncorrectItemDialogueLineType"); incorrectItemLineTypeOption.TryGetValue(out var incorrectItemLineType); var incorrectItemLineCountOption = node.GetNodeOptionByName("IncorrectItemNoLines"); incorrectItemLineCountOption.TryGetValue(out var incorrectItemLineCount); + // Process incorrect item content if (incorrectItemLineType == DialogueType.SayMultipleLines) { for (var i = 0; i < incorrectItemLineCount; i++) { - var lineValue = GetPortValue(node.GetInputPortByName($"IncorrectItemDialogueLine{i + 1}")); - if (!string.IsNullOrEmpty(lineValue)) + var contentPort = node.GetInputPortByName($"IncorrectItemDialogueContent{i + 1}"); + var contentValue = GetPortValue(contentPort); + + if (contentValue != null) { - runtimeNode.incorrectItemLines.Add(lineValue); + // Add to incorrectItemContent list + runtimeNode.incorrectItemContent.Add(contentValue); + + // Also add to legacy incorrectItemLines list for backward compatibility + if (contentValue.ContentType == DialogueContentType.Text && !string.IsNullOrEmpty(contentValue.Text)) + { + runtimeNode.incorrectItemLines.Add(contentValue.Text); + } } } } else { - var lineValue = GetPortValue(node.GetInputPortByName("IncorrectItemDialogueLine")); - if (!string.IsNullOrEmpty(lineValue)) + var contentPort = node.GetInputPortByName("IncorrectItemDialogueContent"); + var contentValue = GetPortValue(contentPort); + + if (contentValue != null) { - runtimeNode.incorrectItemLines.Add(lineValue); + // Add to incorrectItemContent list + runtimeNode.incorrectItemContent.Add(contentValue); + + // Also add to legacy incorrectItemLines list for backward compatibility + if (contentValue.ContentType == DialogueContentType.Text && !string.IsNullOrEmpty(contentValue.Text)) + { + runtimeNode.incorrectItemLines.Add(contentValue.Text); + } } } runtimeNode.loopThroughIncorrectLines = GetPortValue(node.GetInputPortByName("LoopThroughIncorrectItemLines")); - // Process forbidden item lines + // Get line type and count options for forbidden items var forbiddenItemLineTypeOption = node.GetNodeOptionByName("ForbiddenItemDialogueLineType"); forbiddenItemLineTypeOption.TryGetValue(out var forbiddenItemLineType); var forbiddenItemLineCountOption = node.GetNodeOptionByName("ForbiddenItemNoLines"); forbiddenItemLineCountOption.TryGetValue(out var forbiddenItemLineCount); + // Process forbidden item content if (forbiddenItemLineType == DialogueType.SayMultipleLines) { for (var i = 0; i < forbiddenItemLineCount; i++) { - var lineValue = GetPortValue(node.GetInputPortByName($"ForbiddenItemDialogueLine{i + 1}")); - if (!string.IsNullOrEmpty(lineValue)) + var contentPort = node.GetInputPortByName($"ForbiddenItemDialogueContent{i + 1}"); + var contentValue = GetPortValue(contentPort); + + if (contentValue != null) { - runtimeNode.forbiddenItemLines.Add(lineValue); + // Add to forbiddenItemContent list + runtimeNode.forbiddenItemContent.Add(contentValue); + + // Also add to legacy forbiddenItemLines list for backward compatibility + if (contentValue.ContentType == DialogueContentType.Text && !string.IsNullOrEmpty(contentValue.Text)) + { + runtimeNode.forbiddenItemLines.Add(contentValue.Text); + } } } } else { - var lineValue = GetPortValue(node.GetInputPortByName("ForbiddenItemDialogueLine")); - if (!string.IsNullOrEmpty(lineValue)) + var contentPort = node.GetInputPortByName("ForbiddenItemDialogueContent"); + var contentValue = GetPortValue(contentPort); + + if (contentValue != null) { - runtimeNode.forbiddenItemLines.Add(lineValue); + // Add to forbiddenItemContent list + runtimeNode.forbiddenItemContent.Add(contentValue); + + // Also add to legacy forbiddenItemLines list for backward compatibility + if (contentValue.ContentType == DialogueContentType.Text && !string.IsNullOrEmpty(contentValue.Text)) + { + runtimeNode.forbiddenItemLines.Add(contentValue.Text); + } } } @@ -259,4 +315,4 @@ namespace Editor.Dialogue return fallbackValue; } } -} \ No newline at end of file +} diff --git a/Assets/Editor/Dialogue/DialogueNodes.cs b/Assets/Editor/Dialogue/DialogueNodes.cs index adb4f723..3c2c8e0d 100644 --- a/Assets/Editor/Dialogue/DialogueNodes.cs +++ b/Assets/Editor/Dialogue/DialogueNodes.cs @@ -1,6 +1,7 @@ using UnityEngine; using Unity.GraphToolkit.Editor; using System; +using Dialogue; namespace Editor.Dialogue { @@ -37,8 +38,7 @@ namespace Editor.Dialogue const string LineTypeOptionName = "DialogueLineType"; const string NoLinesOptionName = "NoLines"; const string LoopThroughDefaultLinesOptionName = "LoopThroughDefaultLines"; - const string DefaultDialogueLineOptionName = "DefaultDialogueLine"; - + const string DefaultDialogueContentOptionName = "DefaultDialogueContent"; protected override void OnDefineOptions(IOptionDefinitionContext context) { @@ -47,7 +47,6 @@ namespace Editor.Dialogue .WithDefaultValue(DialogueType.SayOneLine) .Delayed(); - context.AddOption(NoLinesOptionName) .WithDisplayName("Number of Default Lines") .WithDefaultValue(1) @@ -59,6 +58,7 @@ namespace Editor.Dialogue context.AddInputPort("in").Build(); context.AddOutputPort("out").Build(); + // Get line type and count options var lineTypeOption = GetNodeOptionByName(LineTypeOptionName); lineTypeOption.TryGetValue(out var lineType); var lineCountOption = GetNodeOptionByName(NoLinesOptionName); @@ -68,15 +68,21 @@ namespace Editor.Dialogue { for (var i = 0; i < lineCount; i++) { - context.AddInputPort($"{DefaultDialogueLineOptionName}{i + 1}").WithDisplayName($"Default Dialogue Line {i + 1}").Build(); + context.AddInputPort($"{DefaultDialogueContentOptionName}{i + 1}") + .WithDisplayName($"Dialogue Content {i + 1}") + .Build(); } } else { - context.AddInputPort($"{DefaultDialogueLineOptionName}").WithDisplayName("Default Dialogue Line").Build(); + context.AddInputPort($"{DefaultDialogueContentOptionName}") + .WithDisplayName("Dialogue Content") + .Build(); } - context.AddInputPort($"{LoopThroughDefaultLinesOptionName}").WithDisplayName("Loop Through Default Lines?").Build(); + context.AddInputPort($"{LoopThroughDefaultLinesOptionName}") + .WithDisplayName("Loop Through Content?") + .Build(); } } @@ -110,38 +116,39 @@ namespace Editor.Dialogue public class WaitOnSlot : DialogueNode { const string RequiredSlotOptionName = "RequiredSlot"; - // Incorrect item - i.e. not the correct one but also not forbidden const string IncorrectItemLineTypeOptionName = "IncorrectItemDialogueLineType"; const string IncorrectItemNoLinesOptionName = "IncorrectItemNoLines"; const string LoopThroughIncorrectItemLinesOptionName = "LoopThroughIncorrectItemLines"; - const string IncorrectIteDialogueLineOptionName = "IncorrectItemDialogueLine"; - // Explicitely forbidden item + const string IncorrectItemDialogueContentOptionName = "IncorrectItemDialogueContent"; + const string ForbiddenItemLineTypeOptionName = "ForbiddenItemDialogueLineType"; const string ForbiddenItemNoLinesOptionName = "ForbiddenItemNoLines"; const string LoopThroughForbiddenItemLinesOptionName = "LoopThroughForbiddenItemLines"; - const string ForbiddenIteDialogueLineOptionName = "ForbiddenItemDialogueLine"; + const string ForbiddenItemDialogueContentOptionName = "ForbiddenItemDialogueContent"; protected override void OnDefineOptions(IOptionDefinitionContext context) { base.OnDefineOptions(context); - // Incorrect + // Incorrect item options context.AddOption(IncorrectItemLineTypeOptionName) .WithDisplayName("Incorrect Item Line Type") .WithDefaultValue(DialogueType.SayOneLine) .Delayed(); + context.AddOption(IncorrectItemNoLinesOptionName) .WithDisplayName("Number of Incorrect Item Lines") .WithDefaultValue(1) .Delayed(); - - // Forbidden + + // Forbidden item options context.AddOption(ForbiddenItemLineTypeOptionName) .WithDisplayName("Forbidden Item Line Type") .WithDefaultValue(DialogueType.SayOneLine) .Delayed(); + context.AddOption(ForbiddenItemNoLinesOptionName) - .WithDisplayName("Forbidden of Incorrect Item Lines") + .WithDisplayName("Number of Forbidden Item Lines") .WithDefaultValue(1) .Delayed(); } @@ -152,45 +159,59 @@ namespace Editor.Dialogue base.OnDefinePorts(context); - // Incorrect + // Process Incorrect Item content var incorrectItemLineTypeOption = GetNodeOptionByName(IncorrectItemLineTypeOptionName); incorrectItemLineTypeOption.TryGetValue(out var incorrectItemLineType); var incorrectItemLineCountOption = GetNodeOptionByName(IncorrectItemNoLinesOptionName); incorrectItemLineCountOption.TryGetValue(out var incorrectItemLineCount); + // Add DialogueContent ports for incorrect item content if (incorrectItemLineType == DialogueType.SayMultipleLines) { for (var i = 0; i < incorrectItemLineCount; i++) { - context.AddInputPort($"{IncorrectIteDialogueLineOptionName}{i + 1}").WithDisplayName($"Incorrect Item Dialogue Line {i + 1}").Build(); + context.AddInputPort($"{IncorrectItemDialogueContentOptionName}{i + 1}") + .WithDisplayName($"Incorrect Item Content {i + 1}") + .Build(); } } else { - context.AddInputPort($"{IncorrectIteDialogueLineOptionName}").WithDisplayName("Incorrect Item Dialogue Line").Build(); + context.AddInputPort($"{IncorrectItemDialogueContentOptionName}") + .WithDisplayName("Incorrect Item Content") + .Build(); } - context.AddInputPort($"{LoopThroughIncorrectItemLinesOptionName}").WithDisplayName("Loop Through Incorrect Item Lines?").Build(); + context.AddInputPort($"{LoopThroughIncorrectItemLinesOptionName}") + .WithDisplayName("Loop Through Incorrect Content?") + .Build(); - // Forbidden + // Process Forbidden Item content var forbiddenItemLineTypeOption = GetNodeOptionByName(ForbiddenItemLineTypeOptionName); forbiddenItemLineTypeOption.TryGetValue(out var forbiddenItemLineType); var forbiddenItemLineCountOption = GetNodeOptionByName(ForbiddenItemNoLinesOptionName); forbiddenItemLineCountOption.TryGetValue(out var forbiddenItemLineCount); + // Add DialogueContent ports for forbidden item content if (forbiddenItemLineType == DialogueType.SayMultipleLines) { for (var i = 0; i < forbiddenItemLineCount; i++) { - context.AddInputPort($"{ForbiddenIteDialogueLineOptionName}{i + 1}").WithDisplayName($"Forbidden Item Dialogue Line {i + 1}").Build(); + context.AddInputPort($"{ForbiddenItemDialogueContentOptionName}{i + 1}") + .WithDisplayName($"Forbidden Item Content {i + 1}") + .Build(); } } else { - context.AddInputPort($"{ForbiddenIteDialogueLineOptionName}").WithDisplayName("Forbidden Item Dialogue Line").Build(); + context.AddInputPort($"{ForbiddenItemDialogueContentOptionName}") + .WithDisplayName("Forbidden Item Content") + .Build(); } - context.AddInputPort($"{LoopThroughForbiddenItemLinesOptionName}").WithDisplayName("Loop Through Forbidden Item Lines?").Build(); + context.AddInputPort($"{LoopThroughForbiddenItemLinesOptionName}") + .WithDisplayName("Loop Through Forbidden Content?") + .Build(); } } diff --git a/Assets/Scenes/Levels/AppleHillsOverworld.unity b/Assets/Scenes/Levels/AppleHillsOverworld.unity index 281f320a..87b41e6f 100644 --- a/Assets/Scenes/Levels/AppleHillsOverworld.unity +++ b/Assets/Scenes/Levels/AppleHillsOverworld.unity @@ -309,7 +309,7 @@ PrefabInstance: objectReference: {fileID: 517425340} - target: {fileID: 6254953093500072797, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 6303063351359542479, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: m_Sprite @@ -603,7 +603,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6254953093500072797, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 6350287859698694726, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: m_Name @@ -777,7 +777,7 @@ PrefabInstance: objectReference: {fileID: 11400000, guid: 9de0c57af6191384e96e2ba7c04a3d0d, type: 2} - target: {fileID: 6254953093500072797, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 6303063351359542479, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: m_Sprite @@ -1287,7 +1287,7 @@ PrefabInstance: objectReference: {fileID: 11400000, guid: a84cbe9804e13f74e857c55d90cc10d1, type: 2} - target: {fileID: 6254953093500072797, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 6303063351359542479, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: m_Sprite @@ -1412,7 +1412,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7616859841301711022, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] @@ -1972,7 +1972,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7616859841301711022, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} m_RemovedComponents: - {fileID: 592045584872845087, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3} @@ -2283,7 +2283,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7616859841301711022, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3} propertyPath: characterToInteract - value: 1 + value: 2 objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] diff --git a/Assets/Scripts/Dialogue/DialogueComponent.cs b/Assets/Scripts/Dialogue/DialogueComponent.cs index 4317bdbf..be3a2ee1 100644 --- a/Assets/Scripts/Dialogue/DialogueComponent.cs +++ b/Assets/Scripts/Dialogue/DialogueComponent.cs @@ -76,20 +76,29 @@ namespace Dialogue { if (speechBubble == null || !HasAnyLines()) return; + // Advance the dialogue state to move to the next content AdvanceDialogueState(); - // Check if we have DialogueContent available + // Check if we have DialogueContent available (prioritizing the new content system) DialogueContent content = GetCurrentDialogueContent(); + if (content != null) { - // Display the content with the new method that handles both text and images + // Display the content with the method that handles both text and images + // and pass whether there are more lines available for prompt display speechBubble.DisplayDialogueContent(content, HasAnyLines()); + + // Log the content type for debugging + Debug.Log($"Displaying content type: {content.ContentType} - {(content.ContentType == DialogueContentType.Text ? content.Text : content.Image?.name)}"); } else { - // Fall back to legacy text-only method + // Fall back to legacy text-only method if no DialogueContent is available string line = GetCurrentDialogueLine(); speechBubble.DisplayDialogueLine(line, HasAnyLines()); + + // Log for debugging + Debug.Log($"Displaying legacy text: {line}"); } } @@ -139,6 +148,7 @@ namespace Dialogue int index = Mathf.Clamp(currentLineIndex, 0, contentForState.Count - 1); return contentForState[index]; } + return null; // No content for this slot state } else { @@ -281,18 +291,41 @@ namespace Dialogue return; } - // If we have more lines in the current node, advance to the next line - if (currentLineIndex < currentNode.dialogueLines.Count - 1) + // First check if we have any dialogueContent to process + bool hasDialogueContent = currentNode.dialogueContent != null && currentNode.dialogueContent.Count > 0; + + if (hasDialogueContent) { - currentLineIndex++; - return; - } + // If we have dialogueContent and there are more entries, advance to the next one + if (currentLineIndex < currentNode.dialogueContent.Count - 1) + { + currentLineIndex++; + return; + } - // If we should loop through lines, reset the index - if (currentNode.loopThroughLines && currentNode.dialogueLines.Count > 0) + // If we should loop through content, reset the index + if (currentNode.loopThroughLines && currentNode.dialogueContent.Count > 0) + { + currentLineIndex = 0; + return; + } + } + else { - currentLineIndex = 0; - return; + // Fall back to legacy dialogueLines + // If we have more lines in the current node, advance to the next line + if (currentLineIndex < currentNode.dialogueLines.Count - 1) + { + currentLineIndex++; + return; + } + + // If we should loop through lines, reset the index + if (currentNode.loopThroughLines && currentNode.dialogueLines.Count > 0) + { + currentLineIndex = 0; + return; + } } // If we're at a node that doesn't have a next node, we're done diff --git a/Assets/Scripts/UI/PauseMenu.cs b/Assets/Scripts/UI/PauseMenu.cs index 0cf08dde..650500e4 100644 --- a/Assets/Scripts/UI/PauseMenu.cs +++ b/Assets/Scripts/UI/PauseMenu.cs @@ -7,10 +7,34 @@ namespace UI { public class PauseMenu : MonoBehaviour { + private static PauseMenu _instance; + private static bool _isQuitting; + + public static PauseMenu Instance + { + get + { + if (_instance == null && Application.isPlaying && !_isQuitting) + { + _instance = FindAnyObjectByType(); + if (_instance == null) + { + var go = new GameObject("PauseMenu"); + _instance = go.AddComponent(); + // DontDestroyOnLoad(go); + } + } + return _instance; + } + } + [Header("UI References")] [SerializeField] private GameObject pauseMenuPanel; [SerializeField] private GameObject pauseButton; + public event Action OnGamePaused; + public event Action OnGameResumed; + private void Start() { // Subscribe to scene loaded events @@ -32,6 +56,11 @@ namespace UI } } + void OnApplicationQuit() + { + _isQuitting = true; + } + /// /// Sets the pause menu game object active or inactive based on the current level /// -- 2.49.1 From 1224d1ba039eae1f7e2342cbfb6d0519a88518f5 Mon Sep 17 00:00:00 2001 From: Michal Pikulski Date: Wed, 8 Oct 2025 11:31:40 +0200 Subject: [PATCH 3/3] Add text field support for wrap --- Assets/Dialogue/TestAssDialogue.dialoguegraph | 2 +- Assets/Editor/Dialogue/DialogueContentDrawer.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Dialogue/TestAssDialogue.dialoguegraph b/Assets/Dialogue/TestAssDialogue.dialoguegraph index 6a213760..fccb5a23 100644 --- a/Assets/Dialogue/TestAssDialogue.dialoguegraph +++ b/Assets/Dialogue/TestAssDialogue.dialoguegraph @@ -578,7 +578,7 @@ MonoBehaviour: serializedVersion: 2 Hash: 3b750432bd23177050f4f1fac360a6c3 m_Version: 2 - m_Position: {x: 1300.841, y: 141.66953} + m_Position: {x: 1300.841, y: 142.06729} m_Title: DialogueNode m_Tooltip: m_NodePreviewModel: diff --git a/Assets/Editor/Dialogue/DialogueContentDrawer.cs b/Assets/Editor/Dialogue/DialogueContentDrawer.cs index d149e13b..a1f3c57c 100644 --- a/Assets/Editor/Dialogue/DialogueContentDrawer.cs +++ b/Assets/Editor/Dialogue/DialogueContentDrawer.cs @@ -69,8 +69,12 @@ namespace Dialogue.Editor // Draw the appropriate field based on content type if (contentTypeProperty.enumValueIndex == (int)DialogueContentType.Text) { + // Create a custom style with word wrap enabled + GUIStyle wordWrapStyle = new GUIStyle(EditorStyles.textArea); + wordWrapStyle.wordWrap = true; + // Text field with word wrap for multi-line input - textProperty.stringValue = EditorGUI.TextArea(contentFieldRect, textProperty.stringValue); + textProperty.stringValue = EditorGUI.TextArea(contentFieldRect, textProperty.stringValue, wordWrapStyle); } else // Image { -- 2.49.1