스케쥴 : Schedule Sheet
MapEditor
- MapEditor
- MainMenu
- NewMap <완료>
- Save&Load <50% _ Load남음.>
- Exit<0%>
- DrawController <일시정지>
- MapData Load 및 파라메터 셋팅. <40%>
- Tile 및 Obstacle 기본셋팅. <30%>
- BrushController <일시정지>
- Tile 변경. <완료> - 오브젝트 필요
- Obstacle 변경. <0%>
- Obstacle 위치 이동. <0%>
- ToolBox <25%> <일시정지>
- Layout. <50%>
- TileTap. <완료>
- Obstacle Tap.
- ETC
- MapEditor Namespace로 묶음.
- NoticePop Controller 생성.
- GameObjectPooler 생성.
----------------------------------------------------------------------------------------------------------------------------------------
GameObjectPooling 관련.
최적화를 위해 GameObject를 생성하고 삭제하는 횟수를 통제해야한다.
Citys, SimCity를 예로들면 일종의 재활용정책인데, 이를 -Pooling이라고 한다.
그리고 프로젝트마다 GameObjectPooling이 필요할 확율이 높다.
매번 새로 만들기는 귀찮고, 그래서 라이브러리로 사용할 Pooler를 만들어보았다.
ObjectPooling(GameObject 생성할 오브젝트, Transform 부모, int 필요수량)
RemoveObject(Transform 부모, int 지울 수량)
사용 예
using System.Collections.Generic; using UnityEngine; public class ObjectPooler : MonoBehaviour { public Dictionary> restGameobjectDic; void BaseSetting(int count){ restGameobjectDic = new Dictionary >(); }//필자는 싱글톤에서 실행했다. void AddRestGameobjects(string key, GameObject obj, int count) { for (int i = 0; i < count; i++) { restGameobjectDic[key].Add(Instantiate(obj, transform)); } }//GameObject를 관리 리스트에 추가 public void ObjectPooling(GameObject obj, Transform parent, int count) { string listName = parent.name + "s"; int needAddCount=0; if (restGameobjectDic.Count == 0 || restGameobjectDic[listName]== null) { restGameobjectDic.Add(listName,new List ()); } // 필요한 List가 없으면 새로 생성. needAddCount = Mathf.Abs(count - restGameobjectDic[listName].Count); //미리 만들어 놓은 것이 있을 경우를 산정하여, 필요한 수량을 다시 계산. AddRestGameobjects(listName, obj, needAddCount); //Debug.Log(listName + " : " + restGameobjectDic[listName].Count); //총알 장전 PoolObject(restGameobjectDic[listName], parent, count); } void PoolObject(List objList, Transform parent, int count) { for( int i = 0; i < count; i++) { GameObject obj = objList[0]; obj.SetActive(true); obj.transform.SetParent(parent); objList.RemoveAt(0); } }//실질적인 Pooling public void RemoveObject(Transform parent, int count) { string listName = parent.name + "s"; for (int i = 0; i < count; i++) { GameObject obj = parent.GetChild(0).gameObject; obj.SetActive(true); restGameobjectDic[listName].Add(obj); obj.transform.SetParent(transform); obj.SetActive(false); } }//반환받은 GameObject를 보관한다.
오브젝트 위치나 ComponentSetting등은 별도의 Controller가 필요하다.
'GameDevelopmentDiary > Project_SomewhereSaga : 가제(맵 에디터에서 중지)' 카테고리의 다른 글
11일차 (0) | 2019.04.05 |
---|---|
8 - 10일차 (0) | 2019.03.20 |
5일차 (0) | 2019.03.01 |
4일차 (0) | 2019.02.24 |
3일차 (0) | 2019.02.23 |