IEnumerator SpawnLevelPart(GameObject levelPart) { if (lInGameLevelsPart.Count < nbMaxLevelPartInGame) { GameObject LV; LV = Instantiate(levelPart); LV.transform.position = lInGameLevelsPart[lInGameLevelsPart.Count - 1].GetComponentInChildren <EndOfLevel>().transform.position; foreach (GameObject tilemap in LV.GetComponent <LevelPart>().TileMaps) { tilemap.GetComponent <Tilemap>().color = new Color(0.35f + brightness - blueness, 0.35f + brightness, 0.35f + brightness, 255f); } if (brightness + 0.025f <= 0.65f) { brightness += 0.025f; } else if (blueness < 0.5f) { blueness += 0.01f; brightness = 0.65f; } else { brightness = 0.65f; blueness = 0.5f; } SpawnEnemiesFollowingDifficulty(LV); lInGameLevelsPart.Add(LV); } isAlreadySpawning = false; yield return(null); }