Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# Convert range

// if you want to convert a value from one range to another
public float ConvertRange(float value, float range1Min, float range1Max, float range2Min, float range2Max) {
        if (range1Min == range1Max) return value;
        return ((value - range1Min) * (range2Max - range2Min) / (range1Max - range1Min)) + range2Min;
    }
 
PREVIOUS NEXT
Tagged: #Convert #range
ADD COMMENT
Topic
Name
3+3 =