Multi Scene Listener Interfaces

Back


Assembly: CarterGames.MultiScene.Runtime

Namespace: CarterGames.Experimental.MultiScene


There are three interfaces in the asset that work like a multi scene alternative for Awake/OnEnable/ Start in execution order when a scene group is loaded. It is important to note that these do not function like the standard Awake/OnEnable/Start but are called on a scene group loading, after the BeforeScenesLoaded event & before the PostScenesLoaded event.

These interfaces are intended to be implemented when you need logic to run consistently when scenes have changed as they don’t need the user to subscribe to an event to have them run. Each interface has its own method with a naming scheme to match the name of the interface, these can be seen below:

IMultiSceneAwake

public void OnMultiSceneAwake()
{
		// Some code here...
}

IMultiSceneEnable

public void OnMultiSceneEnable()
{
		// Some code here...
}

IMultiSceneStart

public void OnMultiSceneStart()
{
		// Some code here...
}

To help avoid execution ordering issues with larger projects there is attribute you can added to these interface method implementations to order their execution in the manager. The attribute takes an int which is the order it runs in. 0 is the default order for all implementations without the attribute. The ordering works just like other ordering in Unity with negative numbers running before & positive numbers running after the default. An example below:

[MultiSceneOrdered(-100)]
public void OnMultiSceneAwake()
{
		// Some code here...
}