How to access components on a brain's active CinemachineCamera?

I have access to the singular CinemachineBrain in my scene. I can get brain.ActiveVirtualCamera, but that’s of type ICinemachineCamera. Looks like ICinemachineCamera had a VirtualCameraGameObject: GameObject reference in Cinemachine 2.X, but not in 3.X?

Without access to the gameObject, how am I meant to access the components on the active cinemachineCamera? Specifically I need to access the PositionComposer.

Same question for CinemachineCore.CameraActivatedEvent, which seems like the other way I would go about getting the currently active camera.

Can probably just pattern match the ICinemachineCamera to Component and then GetComponent<T> from there.

1 Like

Not sure what you mean by that.

if (brain.ActiveVirtualCamera is Component component)
{
    // get components
}
1 Like

That works! I don’t understand why they’d type the return as an Interface with no reference to the component if in actuality it’s returning the component, but it works. Thanks!

1 Like