ITickable - mariaheine/Zenject-But-Wiki GitHub Wiki
In some cases it is preferable to avoid the extra weight of MonoBehaviours in favour of just normal C# classes. Zenject allows you to do this much more easily by providing interfaces that mirror functionality that you would normally need to use a MonoBehaviour for.
For example, if you have code that needs to run per frame, then you can implement the ITickable
interface:
public class Ship : ITickable
{
public void Tick()
{
// Perform per frame tasks
}
}
Then, to hook it up in an installer:
Container.Bind<ITickable>().To<Ship>().AsSingle();
Or if you don't want to have to always remember which interfaces your class implements, you can use the shortcut described here.
Note that the order that the Tick() is called in for all ITickables is also configurable, as outlined here.
Also note that there are interfaces ILateTickable
and IFixedTickable
which mirror Unity's LateUpdate and FixedUpdated methods