Text Collections
The TextCollection
asset is designed to solve the problem of selecting multiple random texts segments, each with its unique initial character.
Text Sources
The texts in a Text Collection are gathered from one or more source files.
Each text source element has four attributes that determine how the source file's content will be processed and added to the collection.
- The Source File specifies the source file.
- The Separator defines what separator to use when splitting the source text up.
- If Trim Whitespace is toggled, any whitespace at the start or end of the text will be removed.
- The Char Filter string contains a collection of characters that will be filtered out of the source text.
Statistics
The text collection's inspector will display some statistics that will give you an idea about its content. It will show the number of texts in the collection, a breakdown of the distinguishable initials in the text, and several random text samples.
Selecting Texts
If we have a reference to a text collection we can pick a random text from the collection like this:
string text = textCollection.PickRandomText();
However, if we are selecting texts for input sequences, it’s often desirable to have each text begin with a unique initial character. If each sequence has a unique initial, the player can predict which sequence will become targeted. In this case, we can use the FindUniquelyTargetableText
method to find a text that is uniquely targetable among the existing input sequences:
string text = textCollection.FindUniquelyTargetableText();
Creating a new WordCollection
A new WordCollection
can be created from the Assets/Create/Typing Game Kit
menu.
You can also simply duplicate one of the existing collections in the /Typing Game Kit/Assets/Text Collections/
folder.