Last active
June 21, 2021 20:30
-
-
Save nomnomab/d6016edeb881b9e90cb933ae3fb1a8d0 to your computer and use it in GitHub Desktop.
Random number in a range whilst excluding an inner range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int RandomNumberInRange(int min, int max, int minExclusion, int maxExclusion) { | |
int value = Random.Range(min, max + 1 - maxExclusion + minExclusion); | |
value += value >= minExclusion ? maxExclusion - minExclusion : 0; | |
return value; | |
} |
Author
nomnomab
commented
Jun 21, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment