public void AddMonster() { monsterCount = int.Parse(selectedMonsterNumber.text); if (monsterCount > 0) { int monsterCountTemp = monsters.Count; for (int i = 0; i < monsterCount; i++) { GameObject monsterTemp = Instantiate(monsterTemplate, gameObject.transform); if (selectedMonster == "Wolf") { Wolf wolf = new Wolf(); wolf.MonsterData(i + monsterCountTemp); monsterTemp.GetComponent <MonsterDataLoad>().monster = wolf; } else if (selectedMonster == "Bandit") { Bandit bandit = new Bandit(); bandit.MonsterData(i + monsterCountTemp); monsterTemp.GetComponent <MonsterDataLoad>().monster = bandit; } monsterTemplates.Add(monsterTemp); monsters.Add(monsterTemp.GetComponent <MonsterDataLoad>().monster); } } selectedMonsterNumber.text = ""; }