diff --git a/Assets/Prefabs/UI/DialogueBox/Dialogue_horizontal.prefab b/Assets/Prefabs/UI/DialogueBox/Dialogue_horizontal.prefab index abbf723a..73989889 100644 --- a/Assets/Prefabs/UI/DialogueBox/Dialogue_horizontal.prefab +++ b/Assets/Prefabs/UI/DialogueBox/Dialogue_horizontal.prefab @@ -155,12 +155,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ae92ebd4d5916514996eb568425857d8, type: 3} m_Name: m_EditorClassIdentifier: - godImage: {fileID: 301723508729519991} godSprite: {fileID: 21300000, guid: 7b277c8f02a337647888d46b236b7ab9, type: 3} dialogueText: {fileID: 228628327914723149} - actualDialogue: Guillaume T OU ? dialogueTitle: {fileID: 0} - actualTitle: + godSprites: [] --- !u!1 &7377141579387670094 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/UI/DialogueBox/Dialogue_vertical.prefab b/Assets/Prefabs/UI/DialogueBox/Dialogue_vertical.prefab index 4ecfa2b1..2b2bd847 100644 --- a/Assets/Prefabs/UI/DialogueBox/Dialogue_vertical.prefab +++ b/Assets/Prefabs/UI/DialogueBox/Dialogue_vertical.prefab @@ -26,7 +26,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 910646895828460860, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} propertyPath: m_Name - value: Dialogue Variant + value: Dialogue_vertical objectReference: {fileID: 0} - target: {fileID: 910646895828460860, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} propertyPath: m_TagString @@ -36,6 +36,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 2.59 objectReference: {fileID: 0} + - target: {fileID: 1292551081983489310, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: m_PresetInfoIsWorld + value: 0 + objectReference: {fileID: 0} - target: {fileID: 1675780870698966960, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} propertyPath: m_SizeDelta.y value: 3 @@ -68,6 +72,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0.44 objectReference: {fileID: 0} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godImage + value: + objectReference: {fileID: 8304963460156740912} - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} propertyPath: actualTitle value: Mort @@ -76,6 +84,38 @@ PrefabInstance: propertyPath: dialogueTitle value: objectReference: {fileID: 19067184449769918} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.size + value: 7 + objectReference: {fileID: 0} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[0] + value: + objectReference: {fileID: 21300000, guid: 977ca8f4471cd4f84bc0276c1506f657, type: 3} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[1] + value: + objectReference: {fileID: 21300000, guid: cd8010b4a55649e47acb2c3b78319df6, type: 3} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[2] + value: + objectReference: {fileID: 21300000, guid: 158a5e6ba97426c4ca5423dc9e3c3922, type: 3} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[3] + value: + objectReference: {fileID: 21300000, guid: 578a517c9ec12ee44aaa76f1147599e7, type: 3} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[4] + value: + objectReference: {fileID: 21300000, guid: 7b277c8f02a337647888d46b236b7ab9, type: 3} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[5] + value: + objectReference: {fileID: 21300000, guid: b52240867e1f249d6966bc5f94d00c6c, type: 3} + - target: {fileID: 4732960806648774282, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + propertyPath: godSprites.Array.data[6] + value: + objectReference: {fileID: 21300000, guid: 0c50372d938694373bd29226386338be, type: 3} - target: {fileID: 4919147100269876766, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} propertyPath: m_StaticEditorFlags value: 0 @@ -224,3 +264,14 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8304963460156740912 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 301723508729519991, guid: 2915528a48cff2a4f972254b123a3e0b, type: 3} + m_PrefabInstance: {fileID: 8606035485087287879} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Resources/UI_God/Mort.png b/Assets/Resources/UI_God/Death.png similarity index 100% rename from Assets/Resources/UI_God/Mort.png rename to Assets/Resources/UI_God/Death.png diff --git a/Assets/Resources/UI_God/Mort.png.meta b/Assets/Resources/UI_God/Death.png.meta similarity index 100% rename from Assets/Resources/UI_God/Mort.png.meta rename to Assets/Resources/UI_God/Death.png.meta diff --git a/Assets/Resources/UI_God/L'envie.png b/Assets/Resources/UI_God/Envy.png similarity index 100% rename from Assets/Resources/UI_God/L'envie.png rename to Assets/Resources/UI_God/Envy.png diff --git a/Assets/Resources/UI_God/L'envie.png.meta b/Assets/Resources/UI_God/Envy.png.meta similarity index 100% rename from Assets/Resources/UI_God/L'envie.png.meta rename to Assets/Resources/UI_God/Envy.png.meta diff --git a/Assets/Resources/UI_God/Gourmandise.png b/Assets/Resources/UI_God/Gluttony.png similarity index 100% rename from Assets/Resources/UI_God/Gourmandise.png rename to Assets/Resources/UI_God/Gluttony.png diff --git a/Assets/Resources/UI_God/Gourmandise.png.meta b/Assets/Resources/UI_God/Gluttony.png.meta similarity index 100% rename from Assets/Resources/UI_God/Gourmandise.png.meta rename to Assets/Resources/UI_God/Gluttony.png.meta diff --git a/Assets/Resources/UI_God/Greed.png b/Assets/Resources/UI_God/Greed.png new file mode 100644 index 00000000..a759dd61 Binary files /dev/null and b/Assets/Resources/UI_God/Greed.png differ diff --git a/Assets/Resources/UI_God/Greed.png.meta b/Assets/Resources/UI_God/Greed.png.meta new file mode 100644 index 00000000..8f27b252 --- /dev/null +++ b/Assets/Resources/UI_God/Greed.png.meta @@ -0,0 +1,114 @@ +fileFormatVersion: 2 +guid: 977ca8f4471cd4f84bc0276c1506f657 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/UI_God/Sloth.png b/Assets/Resources/UI_God/Sloth.png new file mode 100644 index 00000000..54ec574d Binary files /dev/null and b/Assets/Resources/UI_God/Sloth.png differ diff --git a/Assets/Resources/UI_God/Sloth.png.meta b/Assets/Resources/UI_God/Sloth.png.meta new file mode 100644 index 00000000..0a6d9e1f --- /dev/null +++ b/Assets/Resources/UI_God/Sloth.png.meta @@ -0,0 +1,114 @@ +fileFormatVersion: 2 +guid: 0c50372d938694373bd29226386338be +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/UI_God/Vanity.png b/Assets/Resources/UI_God/Vanity.png new file mode 100644 index 00000000..e532fe27 Binary files /dev/null and b/Assets/Resources/UI_God/Vanity.png differ diff --git a/Assets/Resources/UI_God/Vanity.png.meta b/Assets/Resources/UI_God/Vanity.png.meta new file mode 100644 index 00000000..f31109ac --- /dev/null +++ b/Assets/Resources/UI_God/Vanity.png.meta @@ -0,0 +1,114 @@ +fileFormatVersion: 2 +guid: b52240867e1f249d6966bc5f94d00c6c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/Dialogue/DialogueManager.cs b/Assets/Scripts/UI/Dialogue/DialogueManager.cs index 2fdc3c90..6d1ad074 100644 --- a/Assets/Scripts/UI/Dialogue/DialogueManager.cs +++ b/Assets/Scripts/UI/Dialogue/DialogueManager.cs @@ -1,57 +1,165 @@ - namespace DialogueSystem { using System.Collections; - using System.Reflection; + using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; - + using Newtonsoft.Json.Linq; + public class DialogueManager : MonoBehaviour { - private GameObject dialogueCanvas; public Image godImage; - public Sprite godSprite; - public TextMeshProUGUI dialogueText; - public string actualDialogue; - public TextMeshProUGUI dialogueTitle; - public string actualTitle; + public TextMeshProUGUI dialogueText; + public TextMeshProUGUI dialogueTitle; + + private SocketIOUnity clientSocket; + private Queue messageQueue = new Queue(); + private bool isDisplayingMessage = false; + + public List godSprites = new List(); + + private struct GodInfo + { + public Sprite godSprite; + public string godName; + + public GodInfo(Sprite sprite, string name) + { + godSprite = sprite; + godName = name; + } + } + + private struct GodMessage + { + public Sprite godSprite; + public string dialogue; + public string title; + public GodMessage(Sprite sprite, string dialogue, string title) + { + godSprite = sprite; + this.dialogue = dialogue; + this.title = title; + } + } + + private Dictionary godPrefabDictionary = new Dictionary(); private Coroutine hideCanvasCoroutine; void Start() { dialogueCanvas = GameObject.FindGameObjectWithTag("Dialogue"); + clientSocket = SocketManager.Instance.ClientSocket; - if (dialogueCanvas != null) DisplayDialogue(godSprite,actualDialogue,actualTitle); + godPrefabDictionary.Add("1", new GodInfo(godSprites[0], "Greed")); + godPrefabDictionary.Add("2", new GodInfo(godSprites[1], "Chaos")); + godPrefabDictionary.Add("3", new GodInfo(godSprites[2], "Gluttony")); + godPrefabDictionary.Add("4", new GodInfo(godSprites[3], "Envy")); + godPrefabDictionary.Add("5", new GodInfo(godSprites[4], "Death")); + godPrefabDictionary.Add("6", new GodInfo(godSprites[5], "Vanity")); + godPrefabDictionary.Add("7", new GodInfo(godSprites[6], "Sloth")); + + StartCoroutine(ProcessMessageQueue()); } - public void DisplayDialogue(Sprite newGodSprite, string newDialogue,string newTitle) + public void Update() { + clientSocket.On("god:message", response => + { + Debug.Log("Received message from God!"); + Debug.Log(response.ToString()); + + JArray trapDataArray = JArray.Parse(response.ToString()); + JObject messageData = (JObject)trapDataArray[0][0]; + + Debug.Log($"Message data: {messageData}"); + + string godId = messageData["godID"].ToString(); + string messageText = messageData["message"].ToString(); + + Debug.Log($"Received message from God {godId}: {messageText}"); + + // Check if the god ID exists in the dictionary + if (godPrefabDictionary.TryGetValue(godId, out GodInfo godInfo)) + { + Debug.Log($"God with ID '{godId}' found in the dictionary."); + Debug.Log($"God name: {godInfo.godName}"); + EnqueueMessage(godInfo.godSprite, messageText, godInfo.godName); + Debug.Log($"Message enqueued for God {godId}"); + } + else + { + Debug.LogWarning($"God with ID '{godId}' not found in the dictionary."); + } + }); + } + - if (!dialogueCanvas.activeSelf) + private void EnqueueMessage(Sprite godSprite, string dialogue, string title) + { + Debug.Log("Enqueuing message..."); + Debug.Log($"dialogue: {dialogue}, title: {title}"); + messageQueue.Enqueue(new GodMessage(godSprite, dialogue, title)); + } + + private IEnumerator ProcessMessageQueue() + { + while (true) { - dialogueCanvas.SetActive(true); + if (messageQueue.Count > 0 && !isDisplayingMessage) + { + GodMessage nextMessage = messageQueue.Dequeue(); + + Debug.Log("Displaying message..."); + + Debug.Log($"dialogue: {nextMessage.dialogue}, title: {nextMessage.title}"); + + DisplayDialogue(nextMessage.godSprite, nextMessage.dialogue, nextMessage.title); + isDisplayingMessage = true; + + yield return new WaitForSeconds(20f); + + isDisplayingMessage = false; + } + + yield return null; // Attendre le frame suivant } - if (newGodSprite != null)godImage.sprite = newGodSprite; - if (newDialogue != null && newDialogue.Length > 0)dialogueText.text = newDialogue; - if (newTitle != null && newDialogue.Length > 0) dialogueTitle.text = newTitle; + } - if (hideCanvasCoroutine !=null) StopCoroutine(hideCanvasCoroutine); + public void DisplayDialogue(Sprite newGodSprite, string newDialogue, string newTitle) + { + if (!dialogueCanvas.activeSelf) + { + dialogueCanvas.SetActive(true); + } + + if (newGodSprite != null) + { + godImage.sprite = newGodSprite; + } + + dialogueText.text = !string.IsNullOrEmpty(newDialogue) ? newDialogue : ""; + dialogueTitle.text = !string.IsNullOrEmpty(newTitle) ? newTitle : ""; + + if (hideCanvasCoroutine != null) + { + StopCoroutine(hideCanvasCoroutine); + } hideCanvasCoroutine = StartCoroutine(HideCanvasAfterDelay(20f)); } - private IEnumerator HideCanvasAfterDelay(float delay) + + private IEnumerator HideCanvasAfterDelay(float delay) { yield return new WaitForSeconds(delay); - + if (dialogueCanvas != null) { dialogueCanvas.SetActive(false); } } - } - }