IEnumerator CreateMap() { //destroy all children of map parent for (int i = 0; i < mapParent.childCount; i++) { GameObject.Destroy(mapParent.GetChild(i).gameObject); } yield return(new WaitForEndOfFrame()); //use this if you want to select one map in particular //if (mapSelected == 1) { mapSelected = 23; } openedMap = reader.newWad.maps[mapSelected - 1]; //use this if you want to pick a selection of maps to choose from instead of going through the whole list //int[] mapMapper = { 3, 20, 26, 28, 30, 35 }; //openedMap = reader.newWad.maps[mapMapper[(mapSelected - 1) % mapMapper.Length] - 1]; //display map Debug.Log("MAP: " + mapSelected); //read and play music MUS mus = reader.ReadMusEntry(mapSelected - 1); midiplayer.PlayMusic(musmid.WriteMidi(mus, mus.name)); //fill in any missing map information fillInfo(openedMap); float minx = 0; float miny = 0; foreach (Vector3 vert in openedMap.vertexes) { if (vert.x > minx) { minx = vert.x; } if (vert.z > miny) { miny = vert.z; } } skybox.transform.position = new Vector3(minx, 0, miny); //add sectors and monsters to map AddSectors(); SetSkyboxTexture(); AddThings(); skyboxScript.ChangeSky(); }