You are experiencing one of the effects of value-types. Because it copies itself by value, rather than by reference when assigned to new variables or passed as an argument.
You can pass a struct or other value type by ref, using the ref
keyword in your method signature, unfortunately you can't use it for treating a variable in the same stack frame as a reference (i.e. you can't just say ref int test = yourArray[0]
, but must make something like:
public void SomeMethod(ref Vector2 input) {
// now you are modifying the original vector2
}
public void YourOriginalMethod()
{
SomeMethod(yourArray[20]);
}
In response to the comment below, from http://msdn.microsoft.com/en-us/library/14akc2c7.aspx:
Do not confuse the concept of passing by reference with the concept of
reference types. The two concepts are not the same. A method parameter
can be modified by ref regardless of whether it is a value type or a
reference type. There is no boxing of a value type when it is passed
by reference.