To prepare a data entry for the Focus Manager, you can either create a new instance for that data type or get one from the object pool:
FocusPosition positionData = focusManager.GetPooledData<FocusPosition>();
If you plan on adding this data type continuously, it’s a good idea to use the object pool (to avoid too much garbage collection). Either way, whether you create a new data object or retrieve one from the pool, its timestamp will automatically be set to the current Time.realtimeSinceStartup.
After you’ve filled in the data object with the relevant information, submit it to the focus manager with the AddFocusData()
method:
FocusPosition focusPosition = focusManager.GetPooledData<FocusPosition>();
focusPosition.Position = ...
focusPosition.Normal = ...
focusManager.AddFocusData(focusPosition);
To add data continuously, you can subscribe to the OnCaptureFocus
event on the focus manager.
See the GazeFocus and MouseFocus scripts in the Samples/Focus directory for a full example of adding data to the focus manager.
Note that the Focus Manager is responsible for discarding old entries. Once an entry is older than the history window, it will either be returned to the object pool or destroyed, as appropriate.