diff --git a/Assets/Fungus/Scripts/Components/Writer.cs b/Assets/Fungus/Scripts/Components/Writer.cs index a4958c29..667c3281 100644 --- a/Assets/Fungus/Scripts/Components/Writer.cs +++ b/Assets/Fungus/Scripts/Components/Writer.cs @@ -736,6 +736,8 @@ namespace Fungus protected virtual void NotifyGlyph() { + WriterSignals.DoWriterGlyph(this); + foreach (IWriterListener writerListener in writerListeners) { writerListener.OnGlyph(); diff --git a/Assets/Fungus/Scripts/Signals/WriterSignals.cs b/Assets/Fungus/Scripts/Signals/WriterSignals.cs index f1c07a6c..bcf0365e 100644 --- a/Assets/Fungus/Scripts/Signals/WriterSignals.cs +++ b/Assets/Fungus/Scripts/Signals/WriterSignals.cs @@ -32,6 +32,13 @@ namespace Fungus public static event WriterInputHandler OnWriterInput; public static void DoWriterInput(Writer writer) { if (OnWriterInput != null) OnWriterInput(writer); } + /// + /// WriterGlyph signal. Sent when the writer writes out a glyph. + /// + public delegate void WriterGlyphHandler(Writer writer); + public static event WriterGlyphHandler OnWriterGlyph; + public static void DoWriterGlyph(Writer writer) { if (OnWriterGlyph != null) OnWriterGlyph(writer); } + #endregion } } diff --git a/Assets/Tests/Signals/WriterSignalsTester.cs b/Assets/Tests/Signals/WriterSignalsTester.cs index be952034..323b47a3 100644 --- a/Assets/Tests/Signals/WriterSignalsTester.cs +++ b/Assets/Tests/Signals/WriterSignalsTester.cs @@ -11,12 +11,14 @@ namespace Fungus { int correctTagCount = 0; bool receivedInput = false; + int glyphCount = 0; void OnEnable() { WriterSignals.OnTextTagToken += OnTextTagToken; WriterSignals.OnWriterState += OnWriterState; WriterSignals.OnWriterInput += OnWriterInput; + WriterSignals.OnWriterGlyph += OnWriterGlyph; } void OnDisable() @@ -24,6 +26,7 @@ namespace Fungus WriterSignals.OnTextTagToken -= OnTextTagToken; WriterSignals.OnWriterState -= OnWriterState; WriterSignals.OnWriterInput -= OnWriterInput; + WriterSignals.OnWriterGlyph -= OnWriterGlyph; } void OnTextTagToken(Writer writer, TextTagToken token, int index, int maxIndex) @@ -72,6 +75,11 @@ namespace Fungus IntegrationTest.Fail(); } + if (glyphCount != 6) + { + IntegrationTest.Fail(); + } + IntegrationTest.Pass(); } } @@ -80,5 +88,10 @@ namespace Fungus { receivedInput = true; } + + void OnWriterGlyph(Writer writer) + { + glyphCount++; + } } } \ No newline at end of file