One of the most straightforward methods of converting an arbitrary range to a fixed 0 to 1 range, is to use Inverse Lerp.
This works in a similar way to Lerp, which is used to modify a value range using a simple 0-1 control, except that it takes an arbitrary range first and converts it into a 0-1 value.
A common use case of Inverse Lerp is to convert an input axis, which is commonly a float value between -1 and 1, to a 0-1 value range so that it can be used to control other values using Lerp, particularly where the centre point of the axis, normally zero, would need to represent half way on a traditional 0-1 value.
Like this:
void SetRotationControl(float rotationValue)
{
if (PlayerSettings.invertCameraRotation)
{
rotationValue *= -1;
}
rotationControl = Mathf.InverseLerp(-1, 1, rotationValue);
}
In this example Rotation Control is a 0-1 value that is used to tilt a camera around an object, where 0.5 on the control scale represents the centre, snapping the camera back to its default position.
Inverse Lerp is used to turn the input axis into a 0-1 value, where 0.5, not 0, is the centre.