internal static Vector3 DoPlanarHandle(PrincipleAxis2 planeID, Vector3 position, Quaternion rotation, float handleSize, bool snapping, Vector3[] snapVertices, CSGHandles.InitFunction initFunction, InitFunction shutdownFunction = null)
        {
            int moveHandleHash = 0;

            switch (planeID)
            {
            case PrincipleAxis2.XZ:
            {
                moveHandleHash = s_xzAxisMoveHandleHash;
                break;
            }

            case PrincipleAxis2.XY:
            {
                moveHandleHash = s_xyAxisMoveHandleHash;
                break;
            }

            case PrincipleAxis2.YZ:
            {
                moveHandleHash = s_yzAxisMoveHandleHash;
                break;
            }
            }
            int id = GUIUtility.GetControlID(moveHandleHash, FocusType.Keyboard);

            return(DoPlanarHandle(id, planeID, position, rotation, handleSize, snapping, snapVertices, initFunction, shutdownFunction));
        }
        internal static Vector3 DoPlanarHandle(int id, PrincipleAxis2 planeID, Vector3 position, Quaternion rotation, float handleSize, bool snapping, Vector3[] snapVertices, CSGHandles.InitFunction initFunction, InitFunction shutdownFunction = null)
        {
            int axis1index = 0;
            int axis2index = 0;
            var isStatic   = (!Tools.hidden && EditorApplication.isPlaying && ContainsStatic(Selection.gameObjects));

            switch (planeID)
            {
            case PrincipleAxis2.XZ:
            {
                axis1index    = 0;
                axis2index    = 2;
                Handles.color = isStatic? staticColor : Handles.yAxisColor;
                break;
            }

            case PrincipleAxis2.XY:
            {
                axis1index    = 0;
                axis2index    = 1;
                Handles.color = isStatic? staticColor : Handles.zAxisColor;
                break;
            }

            case PrincipleAxis2.YZ:
            {
                axis1index    = 1;
                axis2index    = 2;
                Handles.color = isStatic? staticColor : Handles.xAxisColor;
                break;
            }
            }

            int axisNormalIndex = 3 - axis2index - axis1index;
            var prevColor       = Handles.color;

            var handleTransform             = Matrix4x4.TRS(position, rotation, Vector3.one);
            var sceneView                   = SceneView.currentDrawingSceneView;
            var cameraToTransformToolVector = handleTransform.inverse.MultiplyPoint(sceneView.camera.transform.position).normalized;

            if (Mathf.Abs(cameraToTransformToolVector[axisNormalIndex]) < 0.05f && GUIUtility.hotControl != id)
            {
                Handles.color = prevColor;
                return(position);
            }

            if (EditorGUIUtility.hotControl == 0)
            {
                s_PlanarHandlesOctant[axis1index] = (cameraToTransformToolVector[axis1index] < -0.01f ? -1 : 1);
                s_PlanarHandlesOctant[axis2index] = (cameraToTransformToolVector[axis2index] < -0.01f ? -1 : 1);
            }
            var handleOffset = s_PlanarHandlesOctant;

            handleOffset[axisNormalIndex] = 0;
            handleOffset = rotation * (handleOffset * handleSize * 0.5f);

            var axis1      = Vector3.zero;
            var axis2      = Vector3.zero;
            var axisNormal = Vector3.zero;

            axis1[axis1index]           = 1;
            axis2[axis2index]           = 1;
            axisNormal[axisNormalIndex] = 1;
            axis1      = rotation * axis1;
            axis2      = rotation * axis2;
            axisNormal = rotation * axisNormal;

            s_Vertices[0] = position + handleOffset + (axis1 + axis2) * handleSize * 0.5f;
            s_Vertices[1] = position + handleOffset + (-axis1 + axis2) * handleSize * 0.5f;
            s_Vertices[2] = position + handleOffset + (-axis1 - axis2) * handleSize * 0.5f;
            s_Vertices[3] = position + handleOffset + (axis1 - axis2) * handleSize * 0.5f;

            var innerColor = Handles.color;
            var outerColor = Color.black;

            innerColor = new Color(innerColor.r, innerColor.g, innerColor.b, 0.1f);
            if (CSGHandles.disabled)
            {
                innerColor = Handles.secondaryColor;
                outerColor = innerColor;
            }
            Handles.DrawSolidRectangleWithOutline(s_Vertices, innerColor, outerColor);

            position = Slider2D(id, position, handleOffset, axisNormal, axis1, axis2, handleSize * 0.5f, RectangleHandleCap, snapping, snapVertices, initFunction, shutdownFunction);

            Handles.color = prevColor;

            return(position);
        }