Greetings,
I’m currently facing a problem regarding update values of several arrays inside a list.
The basic setup is the following: a List containing 3 arrays each comprised of 16 float numbers.
My problem is regarding the update of the each array, whenever I update one, it also affects ALL other arrays present in the list, something that I don’t want to happen. The update of each array is made by calling the FindHomography function.
The code is as follows (for a matter of simplicity I omitted most of the code, however I can post more if needed):
public float[] matrix = new float[16];
public const int arraySize = 16;
public List<float[]> matrixList;
void Start () {
InitMatrixList();
}
void InitMatrixList(){
int numPlanes = manager.numExistPlanes;
matrixList = new List<float[]>();
for(int i = 0; i <= numPlanes; i++){
matrixList.Add(matrix);
Debug.Log ("Matrix added");
}
}
void LateUpdate () {
planeMatrixNum = manager.activePlaneNum;
matrix = matrixList[planeMatrixNum];
FindHomography(ref source, ref destination, ref matrix);
}
Also I don’t really know if it’s relevant since I have very little experience but these matrix values are used within a shader (not written by me).