Is there an int based class/struct like Vector2?

I am currently doing a lot of 2D texture based work, for which I am currently using Vector2 to store x,y coordinates. However, due to Vector2's x and y being floats, I have to typecast a lot in my source. There is no use for the floating point because all of these all pixel based coordinates, and therefore whole numbers. I just use Vector2 because it is handy to store an x and y :)

Is there a class for this, or do I have to write my own struct for this?

Thanks!

There is no such class or struct built into Unity.

Easy to implement though (C#) ...

public struct IntVector2
{
    int x;
    int y;

    int sqrMagnitude
    {
        get { return x * x + y * y; }
    }
}

You would probably want to follow the example of Vector2 and implement as many of its methods as make sense for your application. I've shown sqrMagnitude as an example.

UPDATE: There has since been a Unity update where they added Vector2Int, Vector3Int, and Vector4Int classes with this type of functionality.
I was halfway through making my own structs when I updated unity and noticed Vector3Int autocompleting in intellisense, lol. Better late than never.

I might recommend just writing an extension method, so that you don't have to rewrite everything, like yoyo said.

public static class Vector2Extensions {
    public static IntVector2 ToIntVector2 (this Vector2 vector2) {
        int[] intVector2 = new int[2];
        for (int i = 0; i < 2; ++i) intVector2 _= Mathf.RoundToInt(vector2*);*_
 _*return new IntVector2 (intVector2);*_
 _*}*_
_*}*_
_*public struct IntVector2  {*_
 _*public int x, y;*_
 _*public IntVector2 (int[] xy) {*_
 _*x = xy[0];*_
 _*y = xy[1];*_
 _*}*_ 
_*}*_
_*```*_

You may also use the handy Tuple class. While it may be better to implement the way others have suggested in many (perhaps all) circumstances, this way is still worth a mention.

Tuple<int, int> position = new Tuple<int,int>(5, 8);

It’s a bit weird in context though:

getTile(floor, position.item1, position.item2).isCorner = true;

It’s easy to forget it’s referring to x and y coordinates.