Heads up — there might be a bug in STM 1.12.3 (Unity 2021.3.4) that causes events to be missed after calling Rebuild. Try subscribing to OnCustomEvent and testing it with something like this:
void OnCustomEvent(string eventTag, STMTextInfo info) { Debug.Log("Executing event '" + eventTag + "'\nFrame " + Time.frameCount, gameObject); StartCoroutine(PauseReading()); } IEnumerator PauseReading() { stm.Rebuild(stm.currentReadTime, readAutomatically: false, executeEvents: true); yield return new WaitForSeconds(1f); stm.Rebuild(stm.currentReadTime, readAutomatically: true, executeEvents: true); }
And you can use string like this:
This is a test string<e=event1> with multiple events<e=event2>, but the subsequent events won't fire<e=event3> if we rebuild the mesh.
When I tried this in a fresh project, only event1 was fired.
In this particular case, I think I was able to work around it by just using <pause> and Continue() like you're supposed to. But I did run into some weird edge cases where Rebuild was messing things up (actually, I think my mesh was rebuilding because the bounds was changing when the line finished reading out, and that's what caused Continue() to not work when I first tried it).