Search Unity

Get list of VCAMs in scene?

Discussion in 'Cinemachine' started by Jamez0r, Jan 26, 2021.

  1. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    206
    Hello, I'm wondering if there is a way to get a list of the current VCAMs that are in the scene. I was thinking I might be able to access it from the Brain, but I only see the activeVirtualCamera.

    My reasoning for wanting to be able to get this list is that I have a "base VCAM" and then any number of "cutscene VCAMs". The cutscene VCAMs have higher priority than the base VCAM.

    Lets say several of the cutscene VCAMS are currently enabled, and then I immediately need to disable all of them to go back to just the base VCAM. I'm trying to figure out how to do that - right now I can check what the activeVirtualCamera is, and if it isn't the base VCAM then I can disable it - but if I have multiple cutscene VCAMs enabled, then I wouldn't be disabling all of them.

    I could set up my own way of keeping track of my VCAMs, but I figured there might be some place within the Cinemachine components that I could just get a list of the VCAMs. Thanks for any help!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    CinemachineCore.VirtualCameraCount and CinemachineCore.GetVirtualCamera are what you're looking for. However, it seems to me that it might not be necessary to use them.

    If your cutscenes are driven by a timeline with a CinemachhineTrack to activate the vcams, then you should give those vcams a lower priority than the main vcam, because the CM track on the timeline overrides the priority system.
     
  3. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    206
    Thanks Greg! Perfect :D