As stated by the user BIELIK in this thread, you can rotate an object via swipe using the following code:
#if UNITY_EDITOR
float x = -Input.GetAxis("Mouse X");
#elif UNITY_ANDROID
float x = -Input.touches[0].deltaPosition.x;
#endif
transform.rotation *= Quaternion.AngleAxis(x * speedRotation, Vector3.up);
(of course, you need to attach the component where this belongs to the GameObject you want to rotate)
Note that the first if condition is used to ease testing on the Unity editor, so that you don't need to build the app into your device every time you want to test it (in case you are building for phones).
About the snapping feature, you could use some basic logic:
//call this function from your update method
//snappedAngle is the angle where snapping is fixed (in your drawing, would be 0)
//snapThresholdAngle is the angle you decide to apply the snapping once surpassed (in your case, 30)
CheckSwipeProgress(snappedAngle, snapThresholdAngle) {
float currentAngle = transform.eulerAngles;
if (currentAngle > snappedAngle + snapThresholdAngle) {
snappedAngle = (snappedAngle > 265) ? snappedAngle = 0 : snappedAngle += 90;
}
//in this case we need to implicitly check the negative rotation for the snapped angle 0, since eulerAngles have range [0,360]
else if (currentAngle < snappedAngle - snapThresholdAngle || ((snappedAngle == 0) && currentAngle < 360 - snapThresholdAngle && currentAngle > 270)) {
snappedAngle = (snappedAngle < 5) ? snappedAngle = 270 : snappedAngle -= 90;
}
transform.eulerAngles.y = snappedAngle;
//if you implement interpolation, it would substitute the line right above this one.
}
Notice that for the ternary conditions I try to find the singular cases (270 degrees, or 0 degrees), but I compare with a slightly lower/greater number. It is only to ensure numerical precision (avoiding ==), and it won't have any behavioral impact on your app, because snappedAngle can only be 0, 90, 180, and 270.
Notice as well that you can substitute rotation and eulerAngles with localRotation and localEulerAngles respectively, according to your needs.
Finally, about interpolation, there are plenty of threads that explain how to perform it. Check this one. The only thing to take into account is the singular cases because if you interpolate from 310 to 0 (e.g.), the movement will follow the opposite direction. You will need to interpolate between 310 and 360, and afterward assign the yaw value to 0.