I've created a simple math-related extension method, and would like to add it as a definition to the UnityEngine.Mathf
struct, simply so I can call it from the same type as I would other math functions. Is this possible?
My method:
public static int ZeroIfLess(this Mathf math, int num)
{
if(num < 0)
{
return 0;
}
else
{
return num;
}
}
I also tried adding it as an extension method to System.Math
, but that didn't work either, due to it being static
.
Ideally, I'd like it in UnityEngine.Mathf
, but System.Math
would also be appropriate.