redbluegames / unity-text-typer

Text typing effect for Unity uGUI Text components
MIT License
307 stars 28 forks source link

Cleanup TextTyper to use less state #2

Closed edwardrowe closed 7 years ago

edwardrowe commented 7 years ago

The TextTyper has a couple bad smells that I'd like to get rid of:

Instead I think we should add a function, SplitForTyping that would take a string and an index. It would return a struct that contains a string for the display text, a string for the hidden text, and a list of outstanding tags (which need to be applied but only if they haven't already been applied). Every loop the TextTyper would simply call this function, and act on the data accordingly.

It might not even be a function, but rather a complete class, and it should be unit tested.

edwardrowe commented 7 years ago

Added TypedTextGenerator which is used to generate the print text. I also added unit tests for it.