//using the cross-product is quite effective
//Note: This is quite usefull for rigidbodys...
//but you can also use that for transform with some code adjustments
Vector3 targetDir;
Vector3 currentDir = transform.forward; //whatever your currentDir is
//the cross product returns the axis you want to rotate around
Vector3 crossProduct = Vector3.cross(targetDir, currentDir);
float magnitude = crossProduct.magnitude;
rigidbody.angularVelocity = crossProduct.normalized * speed * magnitude;
Simple Code:
Vector3 currentCameraEulers;
float rotationDPI = 7f; // I didn't remeber how to call better this thing
void Update(){
float cameraX = Input.GetAxisRaw("Mouse X") * rotationDPI;
if(cameraX != 0f){
currentCameraEulers = new Vector3(0, cameraX, 0);
transform.eulerAngles += currentCameraEulers;
}
}