IActionUpdaterService is a flexible and easy-to-use service for Unity, designed to manage and dispatch update-related
actions (FixedUpdate, Update, LateUpdate) outside of MonoBehaviour. It allows for a more modular approach to
handling updates, especially useful in projects using dependency injection frameworks like Zenject.
- Separate update methods (
FixedUpdate,Update,LateUpdate) outsideMonoBehaviour. - Easy subscription and unsubscription of actions.
- Pause functionality to control the execution of update actions.
- Automatic cleanup to prevent memory leaks.
- Import the
IActionUpdaterServicepackage into your Unity project. - Add
ActionUpdaterServiceandActionUpdateDispatcherscripts to your project.
Bind the IActionUpdaterService in your Zenject installer like this:
publicsealedclassServicesInstaller:MonoInstaller{publicoverridevoidInstallBindings(){Container.Bind<IActionUpdaterService>().To<ActionUpdaterService>().AsSingle();}}Don't forget to add to the ProjectContext:
Add the ActionUpdateDispatcher class to the ProjectContext prefab, Bootstrupper or any other object that will be the only one in the game.
Inject IActionUpdaterService into your classes and subscribe to the desired update methods:
publicsealedclassYourClass{privateIActionUpdaterServiceactionUpdater;[Inject]privatevoidConstructor(IActionUpdaterServiceactionUpdater)=>this.actionUpdater=actionUpdater;publicvoidSomeMethod(){actionUpdater.Subscribe(MyUpdateMethod,UpdateType.Update);}privatevoidMyUpdateMethod(){// Your update logic here}}Remember to unsubscribe from the service to prevent memory leaks:
publicvoidOnDestroy(){actionUpdater.Unsubscribe(MyUpdateMethod,UpdateType.Update);}You can pause and resume the execution of update methods:
actionUpdater.SetPause(true);// Pauses updatesactionUpdater.SetPause(false);// Resumes updatesThis project is licensed under the MIT License - see the LICENSE file for details.
Developed by RimuruDev.




