fungus

Open full view…

Write Command, "Clear Text" option not working since latest update

samuraipenguinz
Mon, 13 Feb 2017 14:09:37 GMT

Hi. Since the update, whenever the UI Write command is called, the text will always be cleared, regardless of whether the "Clear Text" option is checked or not. This has broken a few of the HUD elements in my game. Anyone else has experienced this?

samuraipenguinz
Mon, 13 Feb 2017 15:20:17 GMT

A little update: I noticed this happens with the Say command as well, with the "Extend Previous" option. Whether it's checked or not, the previous text always gets cleared. Both the UI Write and Say commands at some point call the Writer component's Write() method, and by debugging the code here and there, I noticed the text gets cleared after the ProcessTokens coroutine is started. I'll keep trying to pinpoint the problem, but the code gets kinda complex from there, so maybe a dev could share some insight in what could be causing this?

samuraipenguinz
Mon, 13 Feb 2017 15:50:02 GMT

Another update: think I've nagged the problem. The ProcessTokens() coroutine calls the DoWords() coroutine when its supposed to display untagged text, and the problem lies within a new piece of code inside the DoWords() method. Previously it looked like this: --- string startText = Text; --- After the update, an if statement has been added: --- // Start with the visible portion of any existing displayed text. string startText = ""; if (visibleCharacterCount > 0 && visibleCharacterCount <= Text.Length) { startText = Text.Substring(0, visibleCharacterCount); } --- That statement verifies if the "visibleCharacterCount" variable is above zero, and from my search within this script, it never is. The only place where "visibleCharacterCount" is attributed before the if statement is in the ProcessTokens() method, where it is set to zero. Therefore, instead of storing the existing text of the string, like it did in the previous Fungus version, the startText variable just stays empty. That effectively clears the text every time. For now, I'll just comment th e newly added piece of code and keep using the previous one (string startText = Text;), because I don't really understand where the "visibleCharacterCount" variable is meant to be incremented, in order to store existing text. But the devs should definitely take a look at this. :D

samuraipenguinz
Mon, 13 Feb 2017 15:59:33 GMT

...Aaand then I realized: commenting that piece of code breaks every tag in the text. Fun times. Back to trying and figuring out a workaround, I guess. One that doesn't break anything else. :(

samuraipenguinz
Mon, 13 Feb 2017 16:47:44 GMT

One final update, before I take a break from this monologue: it seems replacing this code in the ProcessTokens() method... --- visibleCharacterCount = 0; --- ...With this... --- visibleCharacterCount = Text.Length; --- ...Fixes the issue. By setting the "visibleCharacterCount" variable as the amount of existing tokens in the string, the "startText" variable in the DoWords() method will successfully store the text. Thus making the "Clear Text" option in the UI Write command and the "Extend Previous" option in the Say command work as intended. I'm still not sure whether that variable is MEANT to store the amount of pre-existing tokens ("visibleCharacterCount" being very strange wording, in that case), but this has solved my HUD problems, so I'll use it for now.

chrisgregan
Tue, 14 Feb 2017 11:45:20 GMT

HI @samuraipenguinz. Looks like this issue was introduced by the fix for [this bug](https://github.com/snozbot/fungus/issues/569). The visibleCharacterCount is the number of text characters that are currently visible, as opposed to being present but displayed with alpha = 0. Setting it to the Text.Length might fix the issue, but I suspect it's not quite correct as Text.Length would include all the visible and non visible characters in the Text. I've opened a bug to look [into it](https://github.com/snozbot/fungus/issues/569).

chrisgregan
Tue, 21 Feb 2017 18:36:34 GMT

Just pushed a fix for this bug. It's a small change to Writer.cs if you want to apply it now, or else wait for the next release. https://github.com/snozbot/fungus/commit/6f9385cc22414fdfe8aab4a86bb5b3003031b98e

prachibarve
Fri, 24 Mar 2017 12:32:47 GMT

hi, Say Command, “Extend Previous” also stopped working after latest update this updated script fixed the issue. Thanks for the Updated script