Return a value always positiv

Hi there

i know that .ToString always return the value as a String.

for example: number.ToString

But is there somthing like .ToPositive?

i mean return the value always positiv, no matter if the variable is negative or positive.

for example:

var minusnumber = -3;
var number = 0;
number = minusnumber.ToPositive;

The Result: number = 3. Is this possible in that way or do you have to do somthing like this:


or is there an even smarter way? Thanks in advance =)

Basically, you want to take the absolute value of your number. So put it in a Mathf.abs(number) and you’re good to go.