protected virtual void OnEnable()
        {
            for (int i = 0; i < targets.Length; ++i)
            {
                (targets[i] as CinemachineOrbitalTransposer).UpdateInputAxisProvider();
            }

#if UNITY_2021_2_OR_NEWER
            if (!Target.HideOffsetInInspector)
            {
                CinemachineSceneToolUtility.RegisterTool(typeof(FollowOffsetTool));
            }
#endif
        }
Пример #2
0
        protected virtual void OnEnable()
        {
            m_ScreenGuideEditor = new CinemachineScreenComposerGuides();
            m_ScreenGuideEditor.GetHardGuide = () => { return(Target.HardGuideRect); };
            m_ScreenGuideEditor.GetSoftGuide = () => { return(Target.SoftGuideRect); };
            m_ScreenGuideEditor.SetHardGuide = (Rect r) => { Target.HardGuideRect = r; };
            m_ScreenGuideEditor.SetSoftGuide = (Rect r) => { Target.SoftGuideRect = r; };
            m_ScreenGuideEditor.Target       = () => { return(serializedObject); };

            m_GameViewEventCatcher = new GameViewEventCatcher();
            m_GameViewEventCatcher.OnEnable();

            CinemachineDebug.OnGUIHandlers -= OnGUI;
            CinemachineDebug.OnGUIHandlers += OnGUI;
            if (CinemachineSettings.CinemachineCoreSettings.ShowInGameGuides)
            {
                InspectorUtility.RepaintGameView();
            }

#if UNITY_2021_2_OR_NEWER
            CinemachineSceneToolUtility.RegisterTool(typeof(TrackedObjectOffsetTool));
#endif
        }
Пример #3
0
 protected virtual void OnEnable()
 {
     CinemachineSceneToolUtility.RegisterTool(typeof(FollowOffsetTool));
 }
        protected override void OnEnable()
        {
            base.OnEnable();
            Undo.undoRedoPerformed += ResetTargetOnUndo;
            m_PipelineSet.Initialize(
                // GetComponent
                (stage, result) =>
            {
                int numNullComponents = 0;
                foreach (var obj in targets)
                {
                    var vcam = obj as CinemachineVirtualCamera;
                    if (vcam != null)
                    {
                        var c = vcam.GetCinemachineComponent(stage);
                        if (c != null)
                        {
                            result.Add(c);
                        }
                        else
                        {
                            ++numNullComponents;
                        }
                    }
                }
                return(numNullComponents);
            },
                // SetComponent
                (stage, type) =>
            {
                Undo.SetCurrentGroupName("Cinemachine pipeline change");
                foreach (var obj in targets)
                {
                    var vcam        = obj as CinemachineVirtualCamera;
                    Transform owner = vcam == null ? null : vcam.GetComponentOwner();
                    if (owner == null)
                    {
                        continue;     // maybe it's a prefab
                    }
                    var c = vcam.GetCinemachineComponent(stage);
                    if (c != null && c.GetType() == type)
                    {
                        continue;
                    }
                    if (c != null)
                    {
                        Undo.DestroyObjectImmediate(c);
                        vcam.InvalidateComponentPipeline();
                    }
                    if (type != null)
                    {
                        Undo.AddComponent(owner.gameObject, type);
                        vcam.InvalidateComponentPipeline();
                    }
                }
            });

            // We only look at the first target here, on purpose
            if (Target != null && Target.m_LockStageInInspector != null)
            {
                foreach (var s in Target.m_LockStageInInspector)
                {
                    m_PipelineSet.SetStageIsLocked(s);
                }
            }

#if UNITY_2021_2_OR_NEWER
            CinemachineSceneToolUtility.RegisterTool(typeof(FoVTool));
            CinemachineSceneToolUtility.RegisterTool(typeof(FarNearClipTool));
#endif
        }