Hello! I have trouble understanding the following piece of code:
public List<Transform> GetWaypoints()
{
var waveWaypoints = new List<Transform>();
foreach (Transform child in pathPrefab.transform)
{
waveWaypoints.Add(child);
}
return waveWaypoints;
}
My question is: How does unity understand that we are looking for the transform of the waypoints and not the transform of the Path, which we have currently set at 0,0,0?
In other words, how does Unity understand that the variable named āchildā refers to the waypoints within the prefab?
Is it because we are creating a list, so unity is looking for a list of similar things with a transform? Is it because we say āin pathPrefabā and that suggests we are looking for the transform, NOT of the pathPrefab itself, but something within the Prefab (so the waypoints)? Is it something else entirely?
Thanks in advance!