World Group Listeners are powerful components that let you hook into and react to events on World Groupings and perform actions on the World Cells of those Groupings. They are a replacement for Cell Actions, which had to be added to each Asset Chunk individually, an inconvient and non-performant system!
There are a few included World Grouping Listeners, one that serves as a static batching utility and the other as an editor aid for viewing World Cell boundaries.
The real power of World Groupings, however, is in the ability to create custom ones and only hook into the events that you care about.
In this chapter, you can view information about the included Listeners or study how to create a custom Listener!
No matter whether you decide to utilize one of the included Listeners or create your own, assigning the Listener is done in the same way.
On the World component's inspector, navigate to the specific World Grouping you would like to assign the listener to, then specify the number of Listeners you want to use. You can re-order listeners, which can be important depending on the nature of the Listeners you are using (although none of the included listeners should be affected by the order).
Listeners can be disabled at runtime, which is useful for temporarily suspending their functionality or performing in editor test where their functionality is disabled, without having to remove them from the World Grouping list of Listeners.
Ny default, Listeners will report as enabled if they are active in the hierarchy and their enabled property is true, however you can override this logic in custom Listeners if you wish.
Listeners can be created in three different ways:
1) By creating a class that derives from WorldGroupingListener. This is a MonoBehaviour derived base abstract class and allows you to add the Listener to the World Grouping via the inspector.
2) By creating a class that derives from WorldGroupingListenerNonComponent. This is a regular C# base abstract class. Any custom Listeners created in this way must be added to the World Grouping via the World's AddWorldGroupingListener method.
3) By creating a class that implements the IWorldGroupingListener interface. This approach is not recommended as it will require more work on your part, however it is an option if you wish. Again, Listeners created this way will need to be added via the World's AddWorldGroupingListener method.
In addition to being able to remove Listeners via the World's inspector, you can remove Listeners at runtime by calling the World's RemoveWorldGroupingListener method. You will need to pass in a reference to the Listener instance when you use this method, and it can only be used after the World has been initialized.