Page 1 of 2
Super Text Mesh: Issues while manually calling UnRead()
Posted: Tue May 12, 2020 1:39 pm
by Lollie
One thing I've felt while using the native STM support in Dialogue System, is that STM's UnRead() function doesn't seem to get called by the packaged scripts, so it has to be called manually. I've had some luck here - namely, hooking up the continue button's "On Click" event and the STM subtitle text's "On Undrawn" event like the screenshots below.
- Unity_20200513_03-25-35-863.png (81.86 KiB) Viewed 1044 times
(I also had to disable/enable the continue button manually - included scripts don't seem to do this when STM is used.)
However, I cannot figure out how to make UnRead() work correctly after selecting a Standard Menu UI dialogue option. I've tried hooking it up via the button's "On Click" event and the Menu UI script's "On Close" event, but neither seem to do the trick. It feels like STM's Rebuild() gets called immediately after selecting an option.
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Tue May 12, 2020 8:07 pm
by Tony Li
Hi,
You can replace the response button's StandardUIResponseButton script with this one:
STMResponseButton.cs
Code: Select all
public class STMResponseButton : PixelCrushers.DialogueSystem.StandardUIResponseButton
{
public override void OnClick()
{
GetComponentInChildren<SuperTextMesh>().UnRead();
base.OnClick();
}
}
It will call UnRead() before telling the dialogue UI that the button has been clicked.
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Wed May 13, 2020 12:25 am
by Lollie
Sorry, I wasn't clear — I'm trying to set up my UI so that once a response is selected, the
subtitle text plays its UnRead animation.
Here's a gif as an example. Line one unreads correctly (using the setup in my first screenshot above) and plays an animation before continuing. But line two simply disappears after selecting a response, showing the next line immediately.
- ezgif-2-499d39081981.gif (67.11 KiB) Viewed 1039 times
My response button is set up with the same event as the continue button, but this doesn't appear to be the solution. Adding this "UnRead" event to the Standard UI Menu Panel's "On Close" event instead also doesn't fix this.
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Wed May 13, 2020 8:23 pm
by Tony Li
Hi,
Replace the StandardUIResponseButton component with this one and assign the Subtitle Text field:
TestResponseButton.cs
Code: Select all
using System.Collections;
using UnityEngine;
public class TestResponseButton : PixelCrushers.DialogueSystem.StandardUIResponseButton
{
public SuperTextMesh subtitleText;
public override void OnClick()
{
StartCoroutine(UnReadThenClick());
}
IEnumerator UnReadThenClick()
{
subtitleText.UnRead();
yield return new WaitForSeconds(subtitleText.totalUnreadTime);
base.OnClick();
}
}
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Thu May 14, 2020 12:10 am
by Lollie
That did it, thank you so much!
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Thu May 14, 2020 8:29 am
by Tony Li
Glad to help!
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Thu May 14, 2020 10:22 am
by digiwombat
Also, since no on asked, but I'm on this forum posting other things, here's my STMFastForward script for Continue buttons that handles overflow text if there is any:
Code: Select all
public class STMFastForward : PixelCrushers.DialogueSystem.StandardUIContinueButtonFastForward
{
public SuperTextMesh targetTextMesh;
public override void OnFastForward()
{
if(!string.IsNullOrWhiteSpace(targetTextMesh.leftoverText) && !targetTextMesh.reading)
{
targetTextMesh.Continue();
}
else if(targetTextMesh != null && targetTextMesh.reading)
{
targetTextMesh.SpeedRead();
}
else
{
base.OnFastForward();
}
}
}
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Thu May 14, 2020 10:41 am
by Tony Li
Thanks!
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Fri May 15, 2020 7:27 am
by Lollie
digiwombat wrote: ↑Thu May 14, 2020 10:22 amAlso, since no on asked, but I'm on this forum posting other things, here's my STMFastForward script for Continue buttons that handles overflow text if there is any:
This is great, thank you!
I ended up adding a couple tiny patches to both scripts - one to add Tony's Unread() code to your script, but also because I found it was possible to spam the continue/response buttons during UnRead(), which would cause Unread() to play repeatedly.
STMResponseButton.csCode: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// https://www.pixelcrushers.com/phpbb/viewtopic.php?f=3&t=3147
public class STMResponseButton : PixelCrushers.DialogueSystem.StandardUIResponseButton
{
public SuperTextMesh targetTextMesh;
private bool noMoreClick;
public override void OnClick()
{
if(!noMoreClick){
StartCoroutine(UnReadThenClick());
noMoreClick = true;
}
}
IEnumerator UnReadThenClick()
{
targetTextMesh.UnRead();
yield return new WaitForSeconds(targetTextMesh.totalUnreadTime);
base.OnClick();
noMoreClick = false;
}
}
STMFastForward.cs (edited to include patch-fix for the post below)
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;
// https://www.pixelcrushers.com/phpbb/viewtopic.php?f=3&t=3147
public class STMFastForward : PixelCrushers.DialogueSystem.StandardUIContinueButtonFastForward
{
public SuperTextMesh targetTextMesh;
private bool noMoreClick;
private UnityEngine.UI.Button contButton;
public override void Awake()
{
contButton = GetComponent<UnityEngine.UI.Button>();
base.Awake();
}
public override void OnFastForward()
{
var state = DialogueManager.currentConversationState;
if(!string.IsNullOrWhiteSpace(targetTextMesh.leftoverText) && !targetTextMesh.reading)
{
targetTextMesh.Continue();
}
else if(targetTextMesh != null && targetTextMesh.reading)
{
targetTextMesh.SpeedRead();
}
else
{
if(state.hasPCResponses && !state.hasForceAutoResponse)
{
contButton.interactable = false;
}
else if(!state.hasPCResponses)
{
if(!noMoreClick){
noMoreClick = true;
StartCoroutine(UnReadThenFastForward());
}
}
}
}
IEnumerator UnReadThenFastForward()
{
targetTextMesh.UnRead();
yield return new WaitForSeconds(targetTextMesh.totalUnreadTime);
base.OnFastForward();
noMoreClick = false;
contButton.interactable = true;
}
}
Re: Super Text Mesh: Issues while manually calling UnRead()
Posted: Sat May 16, 2020 8:15 am
by Lollie
One more quick question actually: Is there a way to check if the current line has a response menu? I think Digiwombat's fast forward script needs an additional Else If check, to ensure that UnRead() can't be called before the response menu has a chance to open. (Dialogue System Manager's "Continue Button" setting doesn't affect the button for some reason.)