Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug CinemachineBrain exception when loading new scene

Discussion in 'Cinemachine' started by s-sixteen, Oct 25, 2020.

  1. s-sixteen

    s-sixteen

    Joined:
    Aug 22, 2015
    Posts:
    7
    Hi guys, the following exception popped up when updating to Cinemachine v2.6.3:


    What happens is that our custom scene manager hooks SceneManager.sceneLoaded to disable existing level when a minigame (new scene) finished loading. CMB is not present in the minigame scene. In our scene manager handler, the existing CMB is disabled, triggering CinemachineBrain.OnDisable()

    Because OnDisable is triggered directly from SceneManager.sceneLoaded, even though CMB.OnSceneLoaded is removed from SceneManager.sceneLoaded delegate, it is still invoked.
    Thus, SceneManager.sceneLoaded -> CMB.OnSceneLoaded -> CMB.ManualUpdate -> CMB.UpdateFrame0

    Now UpdateFrame0 does not handle updating the frame very well when there is no active CMB in the scene.

    Any idea what to do now? Seems like a simple check for empty List in CMB would suffice to fix this...
     
    Epsilon_Delta likes this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks for reporting this edge case! We'll add a nullcheck for the next release.
     
    sregnault likes this.