Search Unity

Question CinemachineFramingTransposer In The Inspector?

Discussion in 'Cinemachine' started by Payaso_Prince, Jan 18, 2023.

  1. Payaso_Prince

    Payaso_Prince

    Joined:
    Jul 17, 2017
    Posts:
    92
    Hello All,

    I have serialized a field in the inspector for a CinemachineFramingTransposer. But when I try and drag the Virtual Camera into the field, it's not accepted. Is there anyway I can reference the camera's FramingTransposer in the inspector? I am trying to avoid using GetComponent.

    Thanks for taking the time!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Unfortunately no, not with CM 2.x.
    You can do it with CM 3.0, but that isn't released yet.

    You can make the field a VirtualCamera field, do a GetCinemachineComponent() at startup, and cache the result.
     
    Payaso_Prince likes this.
  3. Payaso_Prince

    Payaso_Prince

    Joined:
    Jul 17, 2017
    Posts:
    92
    Ah, I see. Well, at least its possible in CM 3.0. I'm excited for the release.
    Thanks for the reply!

    Edit: Spoke a bit too soon. Still not quite understanding something.
    Does the VirtualCamera require specific settings to get the framing transposer component?

    Here's what the VirtualCamera looks like in the inspector:


    Then I'm trying to access the FramingTransposer this way:
    Code (CSharp):
    1. myVirtualCam.GetComponent<CinemachineFramingTransposer>().m_TrackedObjectOffset = new Vector3(1, 1, 1);
    My problem is that the CinemachineFramingTransposer is always null. :confused:
     
    Last edited: Jan 19, 2023
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You have to use vcam.GetCinemachineComponent<CinemachineFramingTransposer>() because the component is not directly on the vcam GameObject, it's buried deeper.
     
    Payaso_Prince likes this.