public Unit CreateUnit(YBEnum.eUnitName unitName, YBEnum.eColorType colorType, Vector2 position) { // 유닛 프리펩과 모델을 가져온다. GameObject unitPrefab = PrefabsManager.GetInstance().GetUnitPrefab(unitName); GameObject modelPrefab = PrefabsManager.GetInstance().GetModelPrefab(unitName, colorType); // 유닛을 생성한다. GameObject unitGo = Instantiate(unitPrefab, Vector3.zero, Quaternion.identity); // 모델을 생성한다. // 이름을 모델로 변경한다. // 트랜스폼을 조정한다. GameObject modelGo = Instantiate(modelPrefab); modelGo.name = "Model"; modelGo.transform.parent = unitGo.transform; // 유닛의 위치를 변경한다. unitGo.transform.position = position; // 유닛의 태그를 설정한다. unitGo.tag = colorType.ToString(); // 유닛 정보를 초기화 한다. Unit unit = unitGo.GetComponent <Unit>(); if (unit.status == null) { UnitData data = DataManager.GetInstance().GetUnitData(unitName.ToString()); // 유닛 데이터를 복사해서 생성한다. unit.status = new UnitData(data); } return(unit); }
public GameObject GetModelPrefab(YBEnum.eUnitName name, YBEnum.eColorType colorType) { string newName = string.Format("{0}_{1}", name.ToString(), colorType.ToString()); return(dicModelPrefabs[newName]); }