Overriding default Vector3 to Vector2 cast?

Is it possible to override the default Vector3 to Vector2 cast without creating a new struct? Maybe with extension class?
For example, as it is now:

Vector2 v2 = new Vector3(x1,y1,z1); // When we do this

v2 == new Vector2(x1,y1); // True

However I work on a top down game and the behavior I want is:

v2 == new Vector2(x1,z1); // Discard y instead of z

Sure. Stick this into a class.

public static Vector2 ToMyVector3(this Vector3 v3)
{
  return new Vector2(v3.x, v3.z);// Discarding the y instead of z captain.
}

It’s not possible to do it the way you want to. Unfortunately you cannot override any function using extension methods. Extensions methods never take precedence over existing functions with same signatures, they’re only meant to add to functionality, not change it.

You’re going to have to go some other more “verbal” way about it, you could create an extension method for casting it to your own coordinate vector and call it like “ToXZVector2” and/or one that compares also to your custom vector like “EqualsXZVector2” which would return true or false depending on if x and z match.