Rotating a 3D Bow with mouse position

I want a 3d bow to rotate with mouse position.
Right now, I rotate bow depending on whether the mouse cursor is on upper right, upper left, bottom right or bottom left of the screen

Like so:

private void RotateBow()
    {
        transform.rotation = Quaternion.identity;
        //top right
        if (Input.mousePosition.y > Screen.height / 2.0f && Input.mousePosition.x > Screen.width / 2.0f)
        {
            transform.Rotate(0, 315, 0);
        }
        //bottom right
        else if (Input.mousePosition.y <= Screen.height / 2.0f && Input.mousePosition.x > Screen.width / 2.0f)
        {
            transform.Rotate(0, 45, 0);
        }
        //top left
        else if (Input.mousePosition.y > Screen.height / 2.0f && Input.mousePosition.x <= Screen.width / 2.0f)
        {
            transform.Rotate(0, 225, 0);
        }
        //bottom left
        else
        {
            transform.Rotate(0, 135, 0);
        }
    }

But I want it to rotate every possible angle with every movement of the cursor. How do I do that?

It all depends on exactly how you want the bow to behave. If you put the following on game object, it will rotate both vertically and horizontally. Just make sure you put values in for the min and max rotation in the inspector…

using UnityEngine;

public class Test1 : MonoBehaviour
{
    [SerializeField] float minHRot;
    [SerializeField] float maxHRot;
    [SerializeField] float minVRot;
    [SerializeField] float maxVRot;

    float hRot = 0;
    float vRot = 0;

    void Update()
    {
        float newHRot = Input.GetAxis("Mouse X");
        hRot = Mathf.Clamp(hRot + newHRot, minHRot, maxHRot);

        float newVRot = Input.GetAxis("Mouse Y");
        vRot = Mathf.Clamp(vRot + newVRot, minVRot, maxVRot);

        transform.rotation = Quaternion.Euler(-vRot, hRot, 0);
    }
}