Skip to content

Instantly share code, notes, and snippets.

@PopupAsylumUK
Created January 24, 2018 09:36
Show Gist options
  • Save PopupAsylumUK/3d286672dfb4f9402484a45bc8cb621f to your computer and use it in GitHub Desktop.
Save PopupAsylumUK/3d286672dfb4f9402484a45bc8cb621f to your computer and use it in GitHub Desktop.
Extension function for floats to remap it from one range to another
public static class FloatRemapExtension {
public static float Remap(this float value, float min, float max, float fromMin = 0, float fromMax = 1) {
return ((value - fromMin) / (fromMax - fromMin)) * (max - min) + min;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment