public BaseTower GetNewTower(string name) { BaseTower tower = null; TowerData towerData = null; if (TowerData.TryGetValue(name, out towerData)) { var towerGO = new GameObject(); tower = towerGO.AddComponent <BaseTower>(); tower.Data = towerData; tower.name = towerData.Name; towerData.SetCollider(towerGO); towerGO.AddComponent <MeshFilter>().mesh = towerData.Mesh; towerGO.AddComponent <MeshRenderer>().material = towerData.Material; } else { Debug.LogError(name + " is not in the dictionary."); } return(tower); }