Hi, below is a short snipet of the relevant methods:
in the first part i’m iterating through a an array of integers. for each integer i’m getting a different value, also an array of integers that i modify, when a certain condition is met.
Now the strange part is: the source value (_tiles[t].texState through _map.getTexState) shouldn’t be affected - only the copy (int[ ] a) - but somehow the source is being changed.
Output of the getter method below is:
a: “getTextState of 17=0000”
b: “getTextState of 17=1000”
How is that even possible? I assume i’m accidently messing up val/ref here somehow without knowing it.
for (x=0; x < l.Length; x++) {
if (l[x] != -1) {
int[] a = _map.getTexState(l[x]);
for (y=0; y < a.Length; y++) {
if (x==y)
a[y] = 1;
}
int[] b = _map.getTexState(l[x]);
...
public int[] getTexState(int t) {
int[] s = _tiles[t].texState;
string d = "getTextState of " + t.ToString() + "=" + s[0].ToString() + s[1].ToString() + s[2].ToString() + s[3].ToString();
Debug.Log(d);
return s;
}