diff --git a/Assets/Fungus/Narrative/Scripts/DialogParser.cs b/Assets/Fungus/Narrative/Scripts/DialogParser.cs index 09fca4a2..961600f0 100644 --- a/Assets/Fungus/Narrative/Scripts/DialogParser.cs +++ b/Assets/Fungus/Narrative/Scripts/DialogParser.cs @@ -76,6 +76,29 @@ namespace Fungus AddWordsToken(tokens, postText); } } + + // Remove all leading whitespace & newlines after a {c} or {wc} tag + // These characters are usually added for legibility when editing, but are not + // desireable when viewing the text in game. + bool trimLeading = false; + foreach (Token token in tokens) + { + if (trimLeading && + token.type == TokenType.Words) + { + token.param.TrimStart(' ', '\t', '\r', '\n'); + } + + if (token.type == TokenType.Clear || + token.type == TokenType.WaitForInputAndClear) + { + trimLeading = true; + } + else + { + trimLeading = false; + } + } } protected static void AddWordsToken(List tokenList, string words)