From bba07f3ddb112cbda082ba61fab8db6ba234b19c Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 4 Dec 2014 16:26:10 +0000 Subject: [PATCH] Added {m} tag to broadcast a message to all FungusScripts This allows you to broadcast a message to all FungusScripts in the middle of Say story text. --- Assets/Fungus/Dialog/Editor/SayEditor.cs | 3 ++- Assets/Fungus/Dialog/Scripts/Dialog.cs | 4 ++++ Assets/Fungus/Dialog/Scripts/DialogParser.cs | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Dialog/Editor/SayEditor.cs b/Assets/Fungus/Dialog/Editor/SayEditor.cs index 10faf1a5..3481a00c 100644 --- a/Assets/Fungus/Dialog/Editor/SayEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SayEditor.cs @@ -24,7 +24,8 @@ namespace Fungus "\t{wp}, {wp=0.5} Wait on punctuation\n" + "\t{c} Clear\n" + "\t{s}, {s=60} Writing speed (chars per sec)\n" + - "\t{x} Exit"; + "\t{x} Exit" + + "\t{m} Broadcast message"; float pixelHeight = EditorStyles.miniLabel.CalcHeight(new GUIContent(tagsText), EditorGUIUtility.currentViewWidth); EditorGUILayout.SelectableLabel(tagsText, EditorStyles.miniLabel, GUILayout.MinHeight(pixelHeight)); diff --git a/Assets/Fungus/Dialog/Scripts/Dialog.cs b/Assets/Fungus/Dialog/Scripts/Dialog.cs index 637deb86..ebbdfacd 100644 --- a/Assets/Fungus/Dialog/Scripts/Dialog.cs +++ b/Assets/Fungus/Dialog/Scripts/Dialog.cs @@ -243,6 +243,10 @@ namespace Fungus } yield break; + + case TokenType.Message: + FungusScript.BroadcastFungusMessage(token.param); + break; } // Update text writing diff --git a/Assets/Fungus/Dialog/Scripts/DialogParser.cs b/Assets/Fungus/Dialog/Scripts/DialogParser.cs index 1dd93225..3f77986b 100644 --- a/Assets/Fungus/Dialog/Scripts/DialogParser.cs +++ b/Assets/Fungus/Dialog/Scripts/DialogParser.cs @@ -20,7 +20,8 @@ namespace Fungus WaitOnPunctuation, // wp, wp=0.5 Clear, // c Speed, // s, s=60 - Exit // x + Exit, // x + Message // m=MessageName } public class Token @@ -153,6 +154,11 @@ namespace Fungus { type = TokenType.Exit; } + else if (tag.StartsWith("m=")) + { + type = TokenType.Message; + paramText = tag.Substring(2, tag.Length - 2); + } Token token = new Token(); token.type = type;