Bug report : Math.Clampf gives incorrect error message

Is there an official place to report bugs? I couldn’t find one in the forums.

Anyway, this is pretty minor but it sent me round and round until I figured it out. If you only pass 2 ints to Mathf.Clamp() then it tells you it can’t find a version of Clamp() that takes (int, System.Object). (I assume it will do the same with two floats). So I spent a lot of time trying to figure out why it was interpreting my second value as an object. It wasn’t a constant; it was an equation, so I got fooled into trying to convert it with .net functions, etc.

That’s actually not what happens as far as I can tell:

var foo = Mathf.Clamp(5, 6);

Result:

“Assets/NewBehaviourScript.js(3,30): BCE0023: No appropriate version of ‘UnityEngine.Mathf.Clamp’ for the argument list ‘(int, int)’ was found.”

According to the error message, it seems you were in fact trying to pass an int and an Object (because you’re using dynamic typing?), so there’s probably no bug. In any case, for bug reports (that are real bugs :wink: ), use the bug reporter app.

–Eric

Well, I can’t reproduce it now, either. Weird. Because I know that when I added the third parameter (which was actually the first one in the list), the problem immediately disappeared. I didn’t touch the parameter that was somehow being interpreted as an Object. Anyway, very minor issue in any case, and thanks for looking at it.