コード例 #1
0
        void OnCurveChanged(GameObject gObject, AnimatableProperty property)
        {
            RigGoalController[] controllers = gObject.GetComponentsInChildren <RigGoalController>();
            if (controllers.Length > 0)
            {
                if ((ToolsManager.CurrentToolName() == "Animation"))
                {
                    //update all goals' curves
                    UpdateGoalCurve(controllers);
                }
                else
                {
                    //only update rig's root curve
                    UpdateGoalCurve(new RigGoalController[] { controllers[0] });
                }
            }
            if (property != AnimatableProperty.PositionX && property != AnimatableProperty.PositionY && property != AnimatableProperty.PositionZ)
            {
                return;
            }

            if (!Selection.IsSelected(gObject))
            {
                return;
            }

            UpdateCurve(gObject);
        }
コード例 #2
0
        public CommandAddKeyframes(GameObject obj, bool updateCurve = true) : base("Add Keyframes")
        {
            gObject = obj;
            Interpolation interpolation = GlobalState.Settings.interpolation;
            int           frame         = GlobalState.Animation.CurrentFrame;

            bool isHuman = obj.TryGetComponent <RigController>(out RigController skinController);

            if (ToolsManager.CurrentToolName() != "Animation" || !isHuman)
            {
                new CommandAddKeyframe(gObject, AnimatableProperty.PositionX, frame, gObject.transform.localPosition.x, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.PositionY, frame, gObject.transform.localPosition.y, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.PositionZ, frame, gObject.transform.localPosition.z, interpolation, updateCurve).Submit();

                // convert to ZYX euler
                Vector3 angles = ReduceAngles(gObject.transform.localRotation);
                new CommandAddKeyframe(gObject, AnimatableProperty.RotationX, frame, angles.x, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.RotationY, frame, angles.y, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.RotationZ, frame, angles.z, interpolation, updateCurve).Submit();
            }

            CameraController controller  = gObject.GetComponent <CameraController>();
            LightController  lcontroller = gObject.GetComponent <LightController>();

            if (null != controller)
            {
                new CommandAddKeyframe(gObject, AnimatableProperty.CameraFocal, frame, controller.focal, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.CameraFocus, frame, controller.Focus, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.CameraAperture, frame, controller.aperture, interpolation, updateCurve).Submit();
            }
            else if (null != lcontroller)
            {
                new CommandAddKeyframe(gObject, AnimatableProperty.Power, frame, lcontroller.Power, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.ColorR, frame, lcontroller.Color.r, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.ColorG, frame, lcontroller.Color.g, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.ColorB, frame, lcontroller.Color.b, interpolation, updateCurve).Submit();
            }
            else
            {
                // Scale
                Vector3 scale = gObject.transform.localScale;
                new CommandAddKeyframe(gObject, AnimatableProperty.ScaleX, frame, scale.x, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.ScaleY, frame, scale.y, interpolation, updateCurve).Submit();
                new CommandAddKeyframe(gObject, AnimatableProperty.ScaleZ, frame, scale.z, interpolation, updateCurve).Submit();
            }

            if (isHuman && ToolsManager.CurrentToolName() == "Animation")
            {
                foreach (Transform child in gObject.transform)
                {
                    RecursiveAddKeyFrame(child, frame, interpolation);
                }
            }
        }
コード例 #3
0
        void Start()
        {
            OnToolChangedEvent += ToolsManager.OnChangeTool;

            string firstToolName = ToolsManager.CurrentToolName();

            ChangeTab(firstToolName);
            currentToolName = firstToolName;
            //ChangeTool(firstToolName);

            colorPanel = tabButtonsContainer.Find("ColorPanel").gameObject;

            keyboardWindow.localScale        = Vector3.zero;
            numericKeyboardWindow.localScale = Vector3.zero;

            createInstanceVFXPrefab = Resources.Load <GameObject>("VFX/ParticleSpawn");
            deleteInstanceVFXPrefab = Resources.Load <GameObject>("VFX/ParticleDespawn");
        }
コード例 #4
0
 void UpdateFromSelection()
 {
     ClearCurves();
     foreach (GameObject gObject in Selection.SelectedObjects)
     {
         AddCurve(gObject);
         if (gObject.TryGetComponent(out RigController skinController))
         {
             if ((ToolsManager.CurrentToolName() == "Animation"))
             {
                 AddHumanCurve(gObject, skinController);
             }
             else
             {
                 //Only display curve for Rig's root
                 RigGoalController goalController = skinController.RootObject.GetComponent <RigGoalController>();
                 AddGoalCurve(goalController, skinController);
             }
         }
     }
 }
コード例 #5
0
        public void OnRemoveKeyFrame()
        {
            CommandGroup group = new CommandGroup("Remove Keyframe");

            try
            {
                foreach (GameObject gObject in Selection.SelectedObjects)
                {
                    if (gObject.TryGetComponent <RigController>(out RigController controller) && ToolsManager.CurrentToolName() != "Animation")
                    {
                        new CommandRemoveRecursiveKeyframes(gObject).Submit();
                    }
                    else
                    {
                        if (GlobalState.Animation.ObjectHasKeyframeAt(gObject, GlobalState.Animation.CurrentFrame))
                        {
                            new CommandRemoveKeyframes(gObject).Submit();
                        }
                    }
                }