void SpawnVirtualCameraIfNull() { if (m_hVirtualController) { return; } var hVirtualCamera = FindObjectOfType <CinemachineVirtualCamera>(); if (hVirtualCamera == null) { SpawnVirtualCamera(); } m_hVirtualController = hVirtualCamera.gameObject.AddComponent <Camera_CnVirtualController>(); #region Method void SpawnVirtualCamera() { Camera hCameraMain = Camera.main; var hVirtualGO = new GameObject("CM vcam"); hVirtualGO.transform.position = hCameraMain.transform.position; hVirtualCamera = hVirtualGO.AddComponent <CinemachineVirtualCamera>(); hVirtualCamera.m_Lens.OrthographicSize = hCameraMain.orthographicSize; hCameraMain.gameObject.AddComponent <CinemachineBrain>(); } #endregion }
public static void RegisterVirtualController(Camera_CnVirtualController hController) { if (instance == null || hController == null) { return; } m_hinstance.m_hVirtualController = hController; }