// Use this for initialization public void InitTreeGen(List <TreeSegment> posList, int heightTrans, int levelLength, int restCov) { for (int i = 0; i < posList.Count; i++) { GameObject gobj = Instantiate(levelGeneratorPrefab, posList[i].position, transform.rotation); if (posList[i].branch = true) { gobj.GetComponent <LevelGenerator>().SetBranchDirection(posList[i].branchDirection); } levelGenList.Add(gobj); } foreach (var LG in levelGenList) { LG.GetComponent <LevelGenerator>().NewLevelCandidate(); } }