Hi everyone, in one of my scripts I’m getting a null reference exception and I’m trying to figure out why. The console says it’s coming from line 9. I have two Transform Arrays someTransformArray1 and someTransformArray2. Both of them have children and subchildren. I want to make it so someTranformArray1’s subchildren’s sharedMesh equals someTranformArray2’s subchildren’s sharedMesh. Any idea what is causing this null reference exception?
public Transform[] someTransformArray1;
public Transform[] someTransformArray2;
void Awake(){
foreach (Transform child1 in someTransformArray1)
foreach (Transform child2 in someTransformArray2)
foreach (Transform subchild1 in child1)
foreach (Transform subchild2 in child2)
subchild1.GetComponent<MeshFilter>().sharedMesh = subchild2.GetComponent<MeshFilter>().sharedMesh;
}