Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(2 edits)

Thank you! Yeah, STM ended up becoming a pretty big part of this project.

I see what you mean now. The float "readTime" was cached from "theMesh.currentReadTime" on the first frame that the <e> event was triggered. Basically it's the read time of the STM at the point before the text to be backspaced begins. After the <e> event, we continue reading for a few letters, then backspace, then rebuild and continue reading where we left off.

The implementation is not ideal, and I wrote it a couple years ago. There are a couple of yield return nulls that I'm not sure are necessary. But I can see why setting .text might have messed with the read time values.

Without all the print statements and whatnot, it's sort of like...

float readTime = theMesh.currentReadTime;
//wait for mesh to read through the letters that we want to delete
while (theMesh.latestNumber < (backspaceEnd - 1))
{
    yield return null;
}
//cut out the rest of the line and pause for a moment
string originalStr = theMesh.text;
float originalReadDelay = theMesh.readDelay;
theMesh.readDelay = 0f;
yield return null; //for some reason we need this here?
theMesh.text = originalStr.RemoveFromIndexToEnd(backspaceEnd + 1);
theMesh.Rebuild(1f, true);
yield return null; //we need this pause to make sure the text stops reading here
theMesh.SkipToEnd();
yield return new WaitForSeconds(1f);
//delete some chars
int counter = 0;
while (counter < charsToDel)
{
    counter++;
    theMesh.Text = theMesh.text.RemoveFromEnd(1);
    theMesh.Rebuild();
    yield return new WaitForSeconds(currTypeSpeed);
}
yield return new WaitForSeconds(waitTime);
//resume reading
theMesh.readDelay = originalReadDelay;
theMesh._text = originalStr.Remove(backspaceStart, charsToDel);
theMesh.Rebuild(readTime, true);

EDIT: The code formatting is removing my linebreaks for some reason, so this is a little hard to read. But you get the idea.