private void RotateTargets()
        {
            var   boundsQConfig  = GetBoundsQConfig();
            float rotationAmount = InputDeviceManager.Get.MouseDelta.x * SharedSettings.RotationSensitivity;

            EditorUndoEx.RecordObjectTransforms(_targetParents);
            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                OOBB targetOOBB = ObjectBounds.CalcHierarchyWorldOOBB(grabTarget.GameObject, boundsQConfig);
                if (!targetOOBB.IsValid)
                {
                    continue;
                }

                var layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    Quaternion rotation = Quaternion.AngleAxis(rotationAmount, layerGrabSettings.AlignAxis ? grabTarget.SittingPlane.normal : Vector3.up);
                    grabTarget.Transform.RotateAroundPivot(rotation, targetOOBB.Center);
                }
                else
                {
                    Quaternion rotation = Quaternion.AngleAxis(rotationAmount, SharedSettings.AlignAxis ? grabTarget.SittingPlane.normal : Vector3.up);
                    grabTarget.Transform.RotateAroundPivot(rotation, targetOOBB.Center);
                }
            }

            CalculateGrabTargetsAnchorVectors();
        }
        private void RotateTargetsAroundAnchor()
        {
            EditorUndoEx.RecordObjectTransforms(_targetParents);
            float rotationAmount = InputDeviceManager.Get.MouseDelta.x * SharedSettings.RotationSensitivity;

            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                var layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    if (layerGrabSettings.AlignAxis)
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, _grabSurfaceInfo.AnchorNormal);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                    else
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, Vector3.up);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                }
                else
                {
                    if (SharedSettings.AlignAxis)
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, _grabSurfaceInfo.AnchorNormal);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                    else
                    {
                        Quaternion rotation = Quaternion.AngleAxis(rotationAmount, Vector3.up);
                        grabTarget.Transform.RotateAroundPivot(rotation, _grabSurfaceInfo.AnchorPoint);
                        grabTarget.AnchorVector = rotation * grabTarget.AnchorVector;
                    }
                }
            }

            SnapTargetsToSurface();
        }
        private void OffsetTargetsFromAnchor()
        {
            EditorUndoEx.RecordObjectTransforms(_targetParents);
            float scaleFactor = 1.0f + InputDeviceManager.Get.GetMouseCaptureDelta(_deltaCaptureId).x *SharedSettings.OffsetFromAnchorSensitivity;

            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }
                grabTarget.Transform.position = (_grabSurfaceInfo.AnchorPoint + grabTarget.AnchorVectorSnapshot * scaleFactor);
            }

            CalculateGrabTargetsAnchorVectors();
            SnapTargetsToSurface();
        }
        private void ScaleTargets()
        {
            EditorUndoEx.RecordObjectTransforms(_targetParents);
            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget == null)
                {
                    continue;
                }

                //float maxAbsScaleComp = grabTarget.WorldScaleSnapshot.GetMaxAbsComp();
                //float scaleFactor = 1.0f + inputDevice.GetCaptureDelta(_inputDevScaleDeltaCaptureId).x * (Settings.ScaleDeviceSensitivity / maxAbsScaleComp);
                float scaleFactor = 1.0f + InputDeviceManager.Get.GetMouseCaptureDelta(_deltaCaptureId).x *SharedSettings.ScaleSensitivity;

                Vector3 newScale = grabTarget.WorldScaleSnapshot * scaleFactor;
                grabTarget.GameObject.SetHierarchyWorldScaleByPivot(newScale, grabTarget.SittingPoint + grabTarget.SittingPlane.normal * grabTarget.OffsetFromSurface);
            }

            CalculateGrabTargetsAnchorVectors();
            //SnapTargetsToSurface();
        }
        private void SnapTargetsToSurface()
        {
            if (_grabSurfaceInfo.SurfaceType == GrabSurfaceType.Invalid)
            {
                return;
            }

            Surface.ObjectSnapConfig snapConfig = new Surface.ObjectSnapConfig();
            snapConfig.SurfaceHitPoint  = _grabSurfaceInfo.AnchorPoint;
            snapConfig.SurfaceHitNormal = _grabSurfaceInfo.AnchorNormal;
            snapConfig.SurfaceHitPlane  = _grabSurfaceInfo.AnchorPlane;
            snapConfig.SurfaceObject    = _grabSurfaceInfo.SceneRaycastHit.WasAnObjectHit ? _grabSurfaceInfo.SceneRaycastHit.ObjectHit.HitObject : null;

            snapConfig.SurfaceType = Surface.Type.UnityTerrain;
            if (_grabSurfaceInfo.SurfaceType == GrabSurfaceType.Mesh)
            {
                snapConfig.SurfaceType = Surface.Type.Mesh;
            }
            else if (_grabSurfaceInfo.SurfaceType == GrabSurfaceType.Grid)
            {
                snapConfig.SurfaceType = Surface.Type.SceneGrid;
            }
            else if (_grabSurfaceInfo.SurfaceType == GrabSurfaceType.SphericalMesh)
            {
                snapConfig.SurfaceType = Surface.Type.SphericalMesh;
            }
            else if (_grabSurfaceInfo.SurfaceType == GrabSurfaceType.TerrainMesh)
            {
                snapConfig.SurfaceType = Surface.Type.TerrainMesh;
            }

            EditorUndoEx.RecordObjectTransforms(_targetParents);
            foreach (var grabTarget in _grabTargets)
            {
                if (grabTarget.GameObject == null)
                {
                    continue;
                }
                grabTarget.Transform.position = _grabSurfaceInfo.AnchorPoint + grabTarget.AnchorVector;

                var layerGrabSettings = SharedSettings.GetLayerGrabSettings(grabTarget.GameObject.layer);
                if (layerGrabSettings.IsActive)
                {
                    snapConfig.AlignAxis         = layerGrabSettings.AlignAxis;
                    snapConfig.AlignmentAxis     = layerGrabSettings.AlignmentAxis;
                    snapConfig.OffsetFromSurface = layerGrabSettings.DefaultOffsetFromSurface + grabTarget.OffsetFromSurface;
                }
                else
                {
                    snapConfig.AlignAxis         = SharedSettings.AlignAxis;
                    snapConfig.AlignmentAxis     = SharedSettings.AlignmentAxis;
                    snapConfig.OffsetFromSurface = SharedSettings.DefaultOffsetFromSurface + grabTarget.OffsetFromSurface;
                }

                var snapResult = Surface.SnapHierarchy(grabTarget.GameObject, snapConfig);
                if (snapResult.WasSnapped)
                {
                    grabTarget.SittingPlane = snapResult.SittingPlane;
                    grabTarget.SittingPoint = snapResult.SittingPoint;
                }
            }
        }