using UnityEditor; namespace Unity.Cinemachine.Editor { [CustomEditor(typeof(CinemachineRotationComposer))] [CanEditMultipleObjects] class CinemachineRotationComposerEditor : CinemachineComponentBaseEditor { readonly GameViewComposerGuides m_GameViewGuides = new(); CinemachineRotationComposer Target => target as CinemachineRotationComposer; protected virtual void OnEnable() { m_GameViewGuides.GetComposition = () => Target.Composition; m_GameViewGuides.SetComposition = (s) => Target.Composition = s; m_GameViewGuides.Target = () => serializedObject; m_GameViewGuides.OnEnable(); CinemachineDebug.OnGUIHandlers -= OnGuiHandler; CinemachineDebug.OnGUIHandlers += OnGuiHandler; if (CinemachineCorePrefs.ShowInGameGuides.Value) InspectorUtility.RepaintGameView(); CinemachineSceneToolUtility.RegisterTool(typeof(TrackedObjectOffsetTool)); } protected virtual void OnDisable() { m_GameViewGuides.OnDisable(); CinemachineDebug.OnGUIHandlers -= OnGuiHandler; if (CinemachineCorePrefs.ShowInGameGuides.Value) InspectorUtility.RepaintGameView(); CinemachineSceneToolUtility.UnregisterTool(typeof(TrackedObjectOffsetTool)); } protected virtual void OnGuiHandler(CinemachineBrain brain) { // Draw the camera guides if (Target == null || !CinemachineCorePrefs.ShowInGameGuides.Value || !Target.isActiveAndEnabled) return; // Don't draw the guides if rendering to texture if (brain == null || brain.OutputCamera == null || (brain.OutputCamera.activeTexture != null && CinemachineBrain.ActiveBrainCount > 1)) return; var vcam = Target.VirtualCamera; if (!brain.IsValidChannel(vcam)) return; // Screen guides bool isLive = targets.Length <= 1 && brain.IsLiveChild(vcam, true); m_GameViewGuides.OnGUI_DrawGuides(isLive, brain.OutputCamera, vcam.State.Lens); // Draw an on-screen gizmo for the target if (Target.LookAtTarget != null && isLive) CmPipelineComponentInspectorUtility.OnGUI_DrawOnscreenTargetMarker( Target.TrackedPoint, brain.OutputCamera); } void OnSceneGUI() { var composer = Target; if (composer == null || !composer.IsValid) return; if (CinemachineSceneToolUtility.IsToolActive(typeof(TrackedObjectOffsetTool))) { CinemachineSceneToolHelpers.TrackedObjectOffsetTool( Target.VirtualCamera, new SerializedObject(Target).FindProperty(() => Target.TargetOffset), CinemachineCore.Stage.Aim); } } } }