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

ActiveBlend False Positive

Discussion in 'Cinemachine' started by FuriousEX, Sep 11, 2021.

  1. FuriousEX

    FuriousEX

    Joined:
    Mar 13, 2014
    Posts:
    51
    Hi - I noticed a case where CinemachineBrain was reporting an ActiveBlend when there was none.

    Specifically this code:

    Code (CSharp):
    1.        
    2.         public CinemachineBlend ActiveBlend
    3.         {
    4.             get
    5.             {
    6.                 if (SoloCamera != null)
    7.                     return null;
    8.  
    9.                 if (mCurrentLiveCameras.CamA == null || mCurrentLiveCameras.IsComplete)
    10.                     return null;
    11.                 return mCurrentLiveCameras;
    12.             }
    13.         }
    14.  
    When I debug in the inspector, mCurrentLiveCameras.CamA has a value of "null" and that fails the null check. My understanding is that Unity only behaves this way in editor - but that could be a gnarly inconsistency.

    I found this hack works:

    Code (CSharp):
    1.  
    2.         public CinemachineBlend ActiveBlend
    3.         {
    4.             get
    5.             {
    6.                 if (SoloCamera != null)
    7.                     return null;
    8.  
    9.                 // JT hack - in editor, "null" interface refs do not equal null
    10.                 if (mCurrentLiveCameras.CamA == null || mCurrentLiveCameras.CamA.Equals(null) || mCurrentLiveCameras.IsComplete)
    11.                     return null;
    12.                 return mCurrentLiveCameras;
    13.             }
    14.         }
    15.  
    16.  
    Thanks,
    JT
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks for that. We will address it in an upcoming release.