Unity 2018.2 Bug with Vector3.Angle

I spent several hours tracking this down last night, and found the solution this morning. This is very strange, but I have this code:

   float angle = Vector3.Angle(curNode.edgeDir,curNode.bisector);

Which works fine in 2018.1, but returns an incorrect “angle” value in 2018.2 In 2018.1 it returns 90, in 2018.2 it returns 0, which breaks the rest of the code in that function.

There are no other changes in my codebase.

When I add this function:

    public static float Anglen(Vector3 from, Vector3 to)
    {
        return Mathf.Acos(Mathf.Clamp(Vector3.Dot(from.normalized, to.normalized), -1f, 1f)) * 57.29578f;
    }

and change the above line to use this new function:

float angle = Anglen(curNode.edgeDir,curNode.bisector);

The code works as expected in 2018.2 as well.

I am guessing this must be a bug? Why would a simple function like Vector3.angle be different between versions?

EDIT: I have just received a notification that 2018.2.8f1 has been released. I don’t know if this fixes the issue, I have been using 2018.2.7f1.

For what it’s worth, you can view the source code here: https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Vector3.cs

You could try copying and pasting that code into your project, then step through it with a debugger to find where it went wrong.

I could do that, thank you, I wasn’t aware of that link.

I can’t see any reason why unity would change that function though.