in my program I have following code:
private void SetCorners<T>(T position, int width, int height)
{
float halfWidth = width / 2 + position.X;
float halfHeight = height / 2 + position.Y;
UpperLeft = new Vector2(-halfWidth, -halfHeight);
UpperRight = new Vector2(halfWidth, -halfHeight);
LowerLeft = new Vector2(-halfWidth, halfHeight);
LowerRight = new Vector2(halfWidth, halfHeight);
}
In which T is either Vector2 or Vector3 from Microsoft.Xna.Framework. This code does not build because T does not contains definition of them.How to make this method works?
You could also create a wrapper class for the two structs:
Sample usage: