I have a property for a vector like this
public Vector2 TestVector
{
get { return testvector; }
set
{
testvector = value;
}
}
the Vector2 has members X and Y.
When I want to set the property.x and property.y to values, it does not work
// this does not work
TestVector.X = 10;
how do I fix this?
edit: I see I am getting answers saying it’s a struct, but really I have a made up class called dVector2, which is a class type not a struct, and I use that. I only put vector2 here for simplicity, but that backfired.
Another solution nobody mentioned is to just make an accessor method for the X and the Y of each vector you have.
Adds a little more code but doesn’t have the extra memory of declaring a new vector every time or the lost encapsulation from making it completely public.