To get the focus data at a particular timestamp, use the GetFocusData<T>(float realtime)
method, where T is the focus data type. This will return the closest focus data entry to the given timestamp (or null, if no entries were found).
foreach (LexiconEntityMatch selectionMatch in runtimeResult.GetEntityMatches(Strings.Selection))
{
FocusSelection focusSelection = focusManager.GetFocusData<FocusSelection>(selectionMatch.RealtimeStart);
if (focusSelection != null)
{
Debug.Log("Selected: " + focusSelection.SelectedObject);
}
}
Note there is an optional second parameter, float maxTimeOffset
, which defaults to 0.5f seconds. This defines the maximum distance allowed to the given timestamp. It is unlikely that any data entries match the given timestamp exactly, so it is important that this value is greater than zero. You can tighten or loosen the range of accepted values by changing this offset.
If you need to guarantee that a data entry occurred after a given timestamp, use the GetFocusDataAfter<T>(float realtime)
method. This will not return any values before the given timestamp.
The Lexicon Runtime automatically retrieves the FocusPosition and FocusSelection for any entity matches. Find them in the LexiconEntityMatch result. This makes actions a little simpler to write.