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

Question InvalidCastException: Unable to cast object of type 'SignalReceiver' to type 'CinemachineBrain'

Discussion in 'Timeline' started by chrismarch, Nov 2, 2021.

  1. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    470
    Our Android player is hitting an exception in the Timeline package code, and we need some help understanding why. We are using a Timeline, and eventually, sometimes, the exception is raised from CinemachineMixer.ProcessFrame when trying to cast the playerData argument:

    Code (CSharp):
    1.         public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    2.         {
    3.             base.ProcessFrame(playable, info, playerData);
    4.  
    5.             // Get the brain that this track controls.
    6.             // Older versions of timeline sent the gameObject by mistake.
    7.             GameObject go = playerData as GameObject;
    8.             if (go == null)
    9.                 mBrain = (CinemachineBrain)playerData;
    Unity 2020.3.16f1, Cinemachine 2.7.8
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    This looks to be a Timeline bug. Can you file a bug report with a repro project?
     
  3. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    470
    We don't know how to repro it yet; we discovered the exception in a released player via our logging agregator. Any clues as to how it might happen might help a repro. I don't follow the code that feeds the wrong object to this method, as it is quite complicated.