Re-subscribing to delegate events on scene change

Hey yall, my app systemetically changes the scene of all clients in a given order. The first time this happens (from scene A->B) it works great. However, after that (B->C etc), my delegate event (IsSceneChangingDidChange) does not fire.

I can also see that the OnRealtimeModelReplaced() method does not run again. I'm not sure how to manually resubscribe to this delegate to listen for model changes when a new scene is loaded. My RealtimeView component this script is attached to is persistent and a singleton.

Here is the method in question:


protected override void OnRealtimeModelReplaced(SceneSyncModel previousModel, SceneSyncModel currentModel)
    {
        
        if (previousModel != null)
        {
            // Unregister from events
            previousModel.isSceneChangingDidChange -= IsSceneChangingDidChange;
        }

        if (currentModel != null)
        {
            if (currentModel.isFreshModel)
            {
                
                currentModel.nextScene = nextScene;
            }

            // Set local variables based on model
            nextScene = model.nextScene;

            currentModel.isSceneChangingDidChange += IsSceneChangingDidChange;
            
        }
    }


Thanks in advance!
Was this page helpful?