The Lexicon Focus Manager is responsible for keeping a history of user focus data that can be correlated with speech and entity results. This is necessary because the Speech to Text and Assistant services are not instantaneous. This is true of any cloud service. But Lexicon aims to match each spoken word with the user’s focus at that precise moment in time (e.g. which object they were looking at, or what position in world space). For this to work, we need a record of everything the user was interacting with over the last several seconds. This is where the Focus Manager comes in.
The Focus Manager keeps lists of LexiconFocusData entries. Each entry has a timestamp, taken from Time.realtimeSinceStartup. Each entry also has focus data according to its type. For example, Lexicon comes with two built-in types:
|FocusPosition||Provides a Vector3 world position and Vector3 surface normal|
|FocusSelection||Provides a selected GameObject|
You can extend the LexiconFocusData class to add your own data types (e.g. controller input, hand positions, etc.)
To use the Focus Manager you must add a data source, such as the MouseFocus or GazeFocus behaviors included in the Samples/Focus folder. Lexicon comes with two prefabs that are already set up for you. Find the LexiconMouse and LexiconGaze prefabs in the Samples/Prefabs folder.
The Focus Manager is a MonoBehaviour, and a singleton. You can add a Focus Manager to your scene, or it will be created for you automatically when any script tries to access it. Be sure to have only one Focus Manager in a scene.
The Buffer Length on the Focus Manager defines how many seconds of history to keep. Ten seconds is a recommended minimum. If you expect longer utterances from your users you may want to increase this buffer length.