Esempio n. 1
0
        void CheckForSelectedAxis()
        {
            ShowProperGizmoType();

            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hitInfo;
                if (Physics.Raycast(transformGizmo.myCamera.ScreenPointToRay(Input.mousePosition), out hitInfo, Mathf.Infinity, mask))
                {
                    Axis          selectedAxis = Axis.None;
                    TransformType type         = transformGizmo.transformType;

                    if (selectedAxis == Axis.None && transformGizmo.TransformTypeContains(TransformType.Move))
                    {
                        selectedAxis = customTranslationGizmos.GetSelectedAxis(hitInfo.collider);
                        type         = TransformType.Move;
                    }
                    if (selectedAxis == Axis.None && transformGizmo.TransformTypeContains(TransformType.Rotate))
                    {
                        selectedAxis = customRotationGizmos.GetSelectedAxis(hitInfo.collider);
                        type         = TransformType.Rotate;
                    }
                    if (selectedAxis == Axis.None && transformGizmo.TransformTypeContains(TransformType.Scale))
                    {
                        selectedAxis = customScaleGizmos.GetSelectedAxis(hitInfo.collider);
                        type         = TransformType.Scale;
                    }

                    transformGizmo.SetTranslatingAxis(type, selectedAxis);
                }
            }
        }
Esempio n. 2
0
        void CheckForSelectedAxis()
        {
            ShowProperGizmoType();

            if (Mouse.current.leftButton.wasPressedThisFrame)
            {
                RaycastHit hitInfo;
                if (Physics.Raycast(transformGizmo.myCamera.ScreenPointToRay(Mouse.current.position.ReadValue()), out hitInfo, Mathf.Infinity, mask))
                {
                    Axis          selectedAxis = Axis.None;
                    TransformType type         = transformGizmo.transformType;

                    if (selectedAxis == Axis.None && transformGizmo.TransformTypeContains(TransformType.Move))
                    {
                        selectedAxis = customTranslationGizmos.GetSelectedAxis(hitInfo.collider);
                        type         = TransformType.Move;
                    }
                    if (selectedAxis == Axis.None && transformGizmo.TransformTypeContains(TransformType.Rotate))
                    {
                        selectedAxis = customRotationGizmos.GetSelectedAxis(hitInfo.collider);
                        type         = TransformType.Rotate;
                    }
                    if (selectedAxis == Axis.None && transformGizmo.TransformTypeContains(TransformType.Scale))
                    {
                        selectedAxis = customScaleGizmos.GetSelectedAxis(hitInfo.collider);
                        type         = TransformType.Scale;
                    }

                    transformGizmo.SetTranslatingAxis(type, selectedAxis);
                }
            }
        }