I have a method:
public void AddQuad(Vector3Int blockPosition, Quad quad)
{
Quad inQuad = quad;
for (int i = 0; i < 4; i++) inQuad.Points += blockPosition;
Quads.Add(inQuad);
}
Where Quad
is a struct
containing a Vector3[]
called points
and Quads
is a Quad[]
in the same class
as this method
when this method runs, it behaves as though the quad parameter was given as a reference.
_inQuad.points += blockPosition;
actually changes the values in the quad that was passed in, instead of only adding a modified version to the array Quads
. Why is this happening? I thought passing a struct
as a parameter created a copy of the struct
, and didn’t alter the original.