Unity Messages (magic methods like OnCollisionEnter) are currently relayed to Bolt through the Unity Message Listener component, which hooks into every known Unity event and forwards them to Bolt’s more extensible Event Bus. This incurs overhead because events that may not be needed are still being hooked into, increasing the pressure on Unity’s internal event system.

In Bolt 2, the Unity Message Listener will be replaced by multiple Unity Message Proxy (UMP) components. Each proxy will register one or more related events (e.g. CollisionMessageProxy could implement OnCollisionEnter, OnCollisionExit and OnCollisionStay) instead of the whole set. UMPs will be added to a game object when a event units start listening, usually in Awake. This will increase the component count on an object and allocate some more memory on instantiation, but it will increase the runtime speed.

Thankfully, the Generated Runtime will usually be able to avoid this sacrifice and thus get the best of both worlds. During generation, each graph will be recursively analyzed to determine the minimal set of events it requires. Those events will then be directly added to the Machine Script as magic methods, eliminating the UMP component overhead.

However, UMPs will still be used in the Generated Runtime for remote event listeners. That is, whenever an event unit listens to a game object event (e.g. OnButtonClick) on a target other than itself. This is a very convenient feature of Bolt 1 that is often used for manager graphs. In this case, the machine script that hosts the listener will add the UMP to the remote target at runtime when it starts listening.