Vector2 Does not contain a definition for 'Abs' (Unity 6)

Any reason why this shows up when I try to publish Unity 6 to Linux, but gives me no problem when I run in the editor? The editor still shows Abs() to be a method of Vector2. Is this a bug?

Unity’s Vector2 type does not contain an “Abs” method, .NET’s System.Numerics.Vector2 does. Perhaps you’re using the wrong (latter) type. It’s odd that this fails in a Linux build, though. Perhaps show the code that is causing an error.

You can use your IDE (if configured properly) to identify what the Abs method is. If it’s in your project, you could be referencing a method / extension method that is not included in the Linux build for whatever reason, like being wrapped in #if UNITY_EDITOR or in an assembly that is not marked as being included in the Linux build.

1 Like

There is no Vector2.Abs method built in: Unity - Scripting API: Vector2

So I would wager that there’s an extension method in your code base or packages that adds this, that might only be available in the editor.

1 Like

Please don’t use the 2D-Physics tag when it’s not a question about it. I’ll go ahead and remove it.

As other have said, you need to figure out who is providing that functionality which any modern IDE would provide.

Thanks.