A Service is a singleton that stores application wide state to provide application wide service.
If you add a Service to a scene, put it under the
Aw-Sim/Services scene hierarchy or click the menu
Create Service in the editorto do that for you. Alternatively you may also add a Service to the
Assets/Resources/Aw-Sim folder in the project.
When a scene loads, the Aw-Sim Framework will do the following:
- It would first attempt to lookup an existing Service so that the state does not change between scenes.
- If no existing Service was found, it would attempt to load it from the scene itself.
- If still not found, it would attempt to load the default Service from the
Assets/Resources/Aw-Simdirectory. This allow adeveloper to open any scene for development/testing and still have the same service loaded.
- If still not found, it would load the build-in Service.
Warning: Do not expose events on a Service, because when GameObjects subscribe to these events and the scene changes, the events might contain unloaded GameObjects.