/// <summary> /// 데코 생성 /// </summary> /// <param name="decorTypeNum">원본 오브젝트 타입(golPrefabNum)</param> /// <param name="prefabIndex">원본 오브젝트 인덱스(golPrefabNum)</param> /// <param name="pos">결과물 오브젝트 position</param> /// <param name="rot">결과물 오브젝트 rotation</param> /// <param name="scl">결과물 오브젝트 scale</param> /// <returns></returns> public Transform Create(int decorTypeNum, int prefabIndex, Vector3 pos, Vector3 rot, Vector3 scl) { // 잘못된 타입 중단 if (decorTypeNum == (int)DecorType.Type.None || decorTypeNum >= DecorType.GetTypeCount()) { return(null); } // 형변환 DecorType.Type dt = (DecorType.Type)decorTypeNum; // 복사 대상이 없을 경우 if (prefabIndex < 0 || prefabIndex >= GetDecorList(dt).Count) { return(null); } // 생성 Transform copyObject = Instantiate( GetDecorList(dt)[prefabIndex], // 복사할 GameObject pos, // position Quaternion.Euler(rot), // rotation decorMaster // 부모 지정 ).transform; // 스케일 지정 copyObject.localScale = scl; //목록 추가 gol.Add(copyObject.gameObject); golTypeNum.Add(decorTypeNum); golPrefabNum.Add(prefabIndex); // 부모 지정 copyObject.SetParent(decorMaster); // 오브젝트 이름 변경 copyObject.name = string.Format("{0} ({1})", GetDecorList(dt)[prefabIndex].name.Split(' ')[0], gol.Count - 1); // 로그 출력 Debug.Log(string.Format("create decor :: {0}\n type={1} typeIndex={2} position=({3}, {4}, {5}) rotation=({6}, {7}, {8}) scale=({9}, {10}, {11})", copyObject.name, decorTypeNum, prefabIndex, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scl.x, scl.y, scl.z)); return(copyObject); }
/// <summary> /// 소분류 드롭다운 새로고침 /// </summary> void SetDropdown(DecorType.Type dt) { // 초기화 category2.options.Clear(); // 목록 추가 for (int i = 0; i < decorManager.GetDecorList(dt).Count; i++) { category2.options.Add( new Dropdown.OptionData( decorManager.GetDecorList(dt)[i].name, null) ); } // 새로고침 category2.RefreshShownValue(); }
/// <summary> /// DecorType.Type으로 적합한 리스트 반환 /// </summary> /// <param name="dt">장식물 타입</param> /// <returns></returns> public List <GameObject> GetDecorList(DecorType.Type dt) { switch (dt) { case DecorType.Type.Bone: return(decorBone); case DecorType.Type.Cactus: return(decorCactus); case DecorType.Type.Obelisk: return(decorObelisk); case DecorType.Type.Plant: return(decorPlant); case DecorType.Type.Pyramid: return(decorPyramid); case DecorType.Type.Rock: return(decorRock); case DecorType.Type.Sand: return(decorSand); case DecorType.Type.Temple: return(decorTemple); case DecorType.Type.Tree: return(decorTree); case DecorType.Type.Oasis: return(decorOasis); default: Debug.Log("null"); return(null); } }