I need to use different midpoint rounding rules than the default "round to even" Mathf.Round() has. Mathf.Round() doesn't have parameter for midpoint rounding, so I'm using System.Math.Round().
C# has different strategies for midpoint rounding, specified here: https://docs.microsoft.com/en-us/dotnet/api/system.midpointrounding?view=net-6.0 . MidpointRounding.AwayFromZero and (obviously) MidpointRounding.ToEven work in Unity, but others, namely MidpointRounding.ToZero don't work, for some reason ("CS0117: 'MidpointRounding' does not contain a definition for 'ToZero'").
float firstN = ...
float lastN = ...
int begin = (int)Math.Round(firstN, MidpointRounding.AwayFromZero); //works
int end = (int)Math.Round(lastN, MidpointRounding.ToZero); //doesn't work
I absolutely need to use MidpointRounding.ToZero, there really isn't any alternatives. I would have to rewrite big parts of the code again. Writing my own rounding function just to solve this one problem doesn't sound fun either.