Lifecycle
The following steps and flowchart describe how Spectacles Sync Kit sets up a Connected Lenses session and when certain actions are safe to do.
Session Setup Steps
- SessionController is initialized.
- SyncEntities in the scene subscribe to events on SessionController.
✅ It is okay to add storage properties, subscribe to events, and request ownership of SyncEntities.
- Instantiators in the scene are initialized and subscribe to events on SessionController.
- On mapping or relocalization success, SessionController begins to set up the session. When the session setup is finished,
SessionController.getIsReady()
becomes true and allSessionController.notifyOnReady()
callbacks are executed.
✅ SessionController is now completely ready to use and SessionController APIs can be called.
- All SyncEntities begin to initialize themselves. Depending on the situation, they may initialize immediately, or may take up to a second to initialize. When each SyncEntity is ready and fully initialized, they execute their
SyncEntity.notifyOnReady()
callbacks.
✅ SyncEntity is now completely ready to use. Storage properties can be set and retrieved, and networked events can be sent and received.
- When each Instantiator is ready and fully initialized, they execute their
Instantiator.notifyOnReady()
callbacks.
✅ Instantiator is now completely ready to use. Prefabs can be instantiated across the network.
Session Setup Flowchart
Key Takeaways
These are the most important points to remember as a developer:
SessionController
- If you need to use SessionController APIs, wait for the
SessionController.notifyOnReady()
callback to run, or forSessionController.getIsReady()
to return true.
SyncEntity
- If you need to set up a SyncEntity by adding storage properties or callbacks, it is fine to do so at any point.
- If you need to make changes to a SyncEntity (e.g., get / set a storage property) or start its behavior, wait for the
SyncEntity.notifyOnReady()
callback, or forSyncEntity.isSetupFinished
to return true.
Instantiator
- If you need to instantiate a prefab using the Instantiator, wait for the
Instantiator.notifyOnReady()
callback, or forInstantiator.isReady()
to return true.
Was this page helpful?