static void CreateBlendListCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Blend List Camera");
            CreateCameraBrainIfAbsent();
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineBlendListCamera), "CM BlendListCamera"),
                typeof(CinemachineBlendListCamera));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create Blend List camera");
            var vcam = go.GetComponent <CinemachineBlendListCamera>();

            // Give it a couple of children
            var child1 = CreateDefaultVirtualCamera();

            Undo.SetTransformParent(child1.transform, go.transform, "create BlendListCam child");
            var child2 = CreateDefaultVirtualCamera();

            child2.m_Lens.FieldOfView = 10;
            Undo.SetTransformParent(child2.transform, go.transform, "create BlendListCam child");

            // Set up initial instruction set
            vcam.m_Instructions = new CinemachineBlendListCamera.Instruction[2];
            vcam.m_Instructions[0].m_VirtualCamera = child1;
            vcam.m_Instructions[0].m_Hold          = 1f;
            vcam.m_Instructions[1].m_VirtualCamera = child2;
            vcam.m_Instructions[1].m_Blend.m_Style = CinemachineBlendDefinition.Style.EaseInOut;
            vcam.m_Instructions[1].m_Blend.m_Time  = 2f;
        }
        static void CreateDollyTrackWithCart(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Dolly Track with Cart");
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineSmoothPath), "DollyTrack"),
                typeof(CinemachineSmoothPath));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create track");
            CinemachineSmoothPath path = go.GetComponent <CinemachineSmoothPath>();

            go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineDollyCart), "DollyCart"),
                typeof(CinemachineDollyCart));
            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create cart");
            go.GetComponent <CinemachineDollyCart>().m_Path = path;
        }
        static void CreateVirtualCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Virtual Camera");
            var go = InternalCreateVirtualCamera(
                "CM vcam", false, typeof(CinemachineComposer), typeof(CinemachineTransposer)).gameObject;

            SetParentToMenuContextObject(go, command);
        }
示例#4
0
        static void CreateDollyTrackWithCart(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Dolly Track with Cart");
            var path = CreateCinemachineObject <CinemachineSmoothPath>(
                "Dolly Track", command.context as GameObject, false);

            CreateCinemachineObject <CinemachineDollyCart>(
                "Dolly Cart", command.context as GameObject, true).m_Path = path;
        }
示例#5
0
        static void CreateStateDivenCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("State-Driven Camera");
            var stateDrivenCamera = CreateCinemachineObject <CinemachineStateDrivenCamera>(
                "State-Driven Camera", command.context as GameObject, true);

            // We give the camera a child as an example setup
            CreateDefaultVirtualCamera(parentObject: stateDrivenCamera.gameObject);
        }
示例#6
0
        static void Create2DCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("2D Camera");
            var vcam = CreateCinemachineObject <CinemachineVirtualCamera>(
                "Virtual Camera", command.context as GameObject, true);

            vcam.m_Lens = MatchSceneViewCamera(vcam.transform);

            AddCinemachineComponent <CinemachineFramingTransposer>(vcam);
        }
示例#7
0
        static void CreateMixingCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Mixing Camera");
            var mixingCamera = CreateCinemachineObject <CinemachineMixingCamera>(
                "Mixing Camera", command.context as GameObject, true);

            // We give the camera a couple of children as an example of setup
            CreateDefaultVirtualCamera(parentObject: mixingCamera.gameObject);
            CreateDefaultVirtualCamera(parentObject: mixingCamera.gameObject);
        }
示例#8
0
        static void CreateClearShotVirtualCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("ClearShot Camera");
            var clearShotCamera = CreateCinemachineObject <CinemachineClearShot>(
                "ClearShot Camera", command.context as GameObject, true);

            // We give the camera a child as an example setup
            var childVcam = CreateDefaultVirtualCamera(parentObject: clearShotCamera.gameObject);

            Undo.AddComponent <CinemachineCollider>(childVcam.gameObject).m_AvoidObstacles = false;
        }
示例#9
0
        static void CreateDollyCameraWithPath(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Dolly Camera with Track");
            var path = CreateCinemachineObject <CinemachineSmoothPath>(
                "Dolly Track", command.context as GameObject, false);
            var vcam = CreateCinemachineObject <CinemachineVirtualCamera>(
                "Virtual Camera", command.context as GameObject, true);

            vcam.m_Lens = MatchSceneViewCamera(vcam.transform);

            AddCinemachineComponent <CinemachineComposer>(vcam);
            AddCinemachineComponent <CinemachineTrackedDolly>(vcam).m_Path = path;
        }
        static void CreateFreeLookCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("FreeLook Camera");
            CreateCameraBrainIfAbsent();
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineFreeLook), "CM FreeLook"),
                typeof(CinemachineFreeLook));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
        }
示例#11
0
        static void CreateTargetGroupCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Target Group Camera");
            var vcam = CreateCinemachineObject <CinemachineVirtualCamera>(
                "Virtual Camera", command.context as GameObject, false);

            vcam.m_Lens = MatchSceneViewCamera(vcam.transform);

            AddCinemachineComponent <CinemachineGroupComposer>(vcam);
            AddCinemachineComponent <CinemachineTransposer>(vcam);

            var targetGroup = CreateCinemachineObject <CinemachineTargetGroup>(
                "Target Group", command.context as GameObject, true);

            vcam.LookAt = targetGroup.transform;
            vcam.Follow = targetGroup.transform;
        }
        static void CreateTargetGroupCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Target Group Camera");
            CinemachineVirtualCamera vcam = InternalCreateVirtualCamera(
                "CM vcam", true, typeof(CinemachineGroupComposer), typeof(CinemachineTransposer));
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineTargetGroup), "TargetGroup"),
                typeof(CinemachineTargetGroup));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create target group");
            vcam.LookAt = go.transform;
            vcam.Follow = go.transform;
        }
        static void CreateStateDivenCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("State-Driven Camera");
            CreateCameraBrainIfAbsent();
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineStateDrivenCamera), "CM StateDrivenCamera"),
                typeof(CinemachineStateDrivenCamera));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create state driven camera");

            // Give it a child
            Undo.SetTransformParent(CreateDefaultVirtualCamera().transform, go.transform, "create state driven camera");
        }
示例#14
0
        static void CreateBlendListCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Blend List Camera");
            var blendListCamera = CreateCinemachineObject <CinemachineBlendListCamera>(
                "Blend List Camera", command.context as GameObject, true);

            // We give the camera a couple of children as an example of setup
            var childVcam1 = CreateDefaultVirtualCamera(parentObject: blendListCamera.gameObject);
            var childVcam2 = CreateDefaultVirtualCamera(parentObject: blendListCamera.gameObject);

            childVcam2.m_Lens.FieldOfView = 10;

            // Set up initial instruction set
            blendListCamera.m_Instructions = new CinemachineBlendListCamera.Instruction[2];
            blendListCamera.m_Instructions[0].m_VirtualCamera = childVcam1;
            blendListCamera.m_Instructions[0].m_Hold          = 1f;
            blendListCamera.m_Instructions[1].m_VirtualCamera = childVcam2;
            blendListCamera.m_Instructions[1].m_Blend.m_Style = CinemachineBlendDefinition.Style.EaseInOut;
            blendListCamera.m_Instructions[1].m_Blend.m_Time  = 2f;
        }
        static void CreateDollyCameraWithPath(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Dolly Camera with Track");
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineSmoothPath), "DollyTrack"),
                typeof(CinemachineSmoothPath));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create track");
            CinemachineSmoothPath path = go.GetComponent <CinemachineSmoothPath>();

            CinemachineVirtualCamera vcam = InternalCreateVirtualCamera(
                "CM vcam", true, typeof(CinemachineComposer), typeof(CinemachineTrackedDolly));

            SetParentToMenuContextObject(vcam.gameObject, command);
            vcam.GetCinemachineComponent <CinemachineTrackedDolly>().m_Path = path;
        }
        static void CreateClearShotVirtualCamera(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("ClearShot Camera");
            CreateCameraBrainIfAbsent();
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineClearShot), "CM ClearShot"),
                typeof(CinemachineClearShot));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create ClearShot camera");

            // Give it a child
            var child = CreateDefaultVirtualCamera();

            Undo.SetTransformParent(child.transform, go.transform, "create ClearShot camera");
            var collider = Undo.AddComponent <CinemachineCollider>(child.gameObject);

            collider.m_AvoidObstacles = false;
            Undo.RecordObject(collider, "create ClearShot camera");
        }
示例#17
0
 static void CreateFreeLookCamera(MenuCommand command)
 {
     CinemachineEditorAnalytics.SendCreateEvent("FreeLook Camera");
     CreateCinemachineObject <CinemachineFreeLook>("FreeLook Camera", command.context as GameObject, true);
 }
示例#18
0
 static void CreateVirtualCamera(MenuCommand command)
 {
     CinemachineEditorAnalytics.SendCreateEvent("Virtual Camera");
     CreateDefaultVirtualCamera(parentObject: command.context as GameObject, select: true);
 }