Search Unity

Hidden GameObject 'cm' created by CinemachineVirtualCamera is getting lost and causes errors

Discussion in 'Cinemachine' started by Xarbrough, Jun 28, 2019.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Cinemachine appears to be creating hidden GameObjects named 'cm' in the scene as a child of CinemachineVirtualCamera components. Occasionally, this seems to cause problems because the objects suddenly become disconnected. In this case the lost 'cm' object suddenly becomes visible an is placed randomly at the root level of the scene. Addditionally, and more important, when working with virtual cameras and prefabs there seem to be issues with this process of creating a hidden object and managing it. Regularly, some of the prefabs throw a slew of warnings and errors with the following info (from memory, I could not obtain the logs for these problems yet):
    - GameObject without Transform detected, must be deleted
    - Deleting of Transform component is not allowed
    - Doing specific operations in prefab mode is not supported

    I could not reproduce these issues in a clean project and so I haven't reported a bug yet, but I still wanted to ask if anyone has had similar issues or simply let the developers know, that there is something wrong with the way Cinemachine handles this hidden GameObject and prefabs.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    Yes, CM by default creates hidden GameObjects named "cm" under the vcams. Normally they are harmless, but in some circumstances (e.g. deleting CinemachineVirtualCamera components, or some ways of using prefabs) they might become orphaned. When this happens, just delete them.

    If your workflow is such that they really get in the way and become annoying, consider using the new experimental versions of vcam and FreeLook. They have been re-implemented without the hidden objects. To use them, define CINEMACHINE_EXPERIMENTAL_VCAM in your player settings and look for CinemachineNewVirtualCamera and CinemachineNewFreeLook in the components menu.
     
  3. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    how do you delete them if they are flagged as hidden in hierarchy? we have a scene with 125 of these. do I have to write a script to clean it up?
     
  4. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    In my case it was enough to just select all "cm" objects in the scene hierarchy window and delete them. These orphaned instances were visible like all regular GameObjects. If yours are still hidden from the hierarchy window, then they are probably still connected correctly and hidden for good reason.

    We haven't run into the same issue since then by the way, but we also regularly upgrade Cinemachine. So maybe there was also a bug fix during the last two years that resolved the issue.
     
    Gregoryl likes this.