전체 글(23)
-
[UnityEngine] UI 선택에 따른 Canvas의 SortingOrder를 재정렬 하는 방법
유저가 팝업창들을 선택할때에 정렬순서를 바꿔주는 기능을 UnityEngine 에서 구현해보자. 여러 팝업UI 들을 패널로 만들어놓고 하나의 Canvas안에 다 넣어놓는 형태는 성능에 좋지않다. Canvas 는 이벤트가 발생할때마다 모든 자식들을 갱신한다. 특히나 ScrollView, Slider 등의 마우스 드래그 처럼 매우많은 이벤트가 발생하는 CanvasRenderer 들은 최대한 Canvas 단위로 잘 분류해서 불필요한 CanvasRenderer 들이 갱신되지 않도록 해 주어야 한다. 그래서 이번 포스팅에서는 장비창, 인벤토리창을 별도의 Canvas로 두고, CanvasManager를 통해 이벤트를 처리하면서 각 Canvas의 SortingOrder 를 재정렬 하도록 해본다. 보통 간단한 UI 팝업..
2022.10.13 -
[UnityEngine] CustomEditor for inheritance
Unity's custom editor dose not support member fields of parent type. So, to show member fields of inherited class on inspector view, I also inherited custom editor for parent class's custom editor. Here some test classes below, I would like to draw a ObjectField that would refers DummyData on [Child] component's inspector view. First, make a Editor for [Parent], define static generic method draw..
2022.10.11 -
[C#] Dynamic의 Reflection
Unity 엔진에서 데이터 분석을 위한 커스텀에디터를 작성하고있는 도중 분석하려는 필드타입이 dynamic 일 경우 Reflection 으로 처리한 과정이다. 그전에 일반적인 필드들에 대해 어떻게 Reflection 으로 처리했는지 먼저 살펴본다. 커스텀에디터의 컨셉은 위와같으며, 멤버필드들의 값 변화를 디버그를 하지않고 시각적으로 바로 체크할 수 있도록 해주는 툴을 제작중이다. 시간에 따라 값이 차트에 그려지고, 차트를 클릭하면 해당 시간에 저장된 필드들의 값이 나타난다. 위의 예시에서, 분석 타겟이 된 객체는 FSM 확장을위한 베이스 클래스를 상속받는 형태의 클래스타입인데, FSM 베이스 클래스를 상속받은 자식클래스들은 각각 고유한 상태들이 필요하므로, 베이스의 StateType 필드는 dynamic..
2022.09.19 -
[C#] IEnumerator, IEnumerable
IEnumerator 는 C++ 에서의 Iterator 처럼, Collection 을 반복(Iteration) 하기위한 인터페이스이다. IEnumerable 은 GetEnumerator() 라는 멤버함수를 노출해서 Collection 을 반복할 수 있도록 하는 인터페이스이다. 결국 배열과같은 연속적인 데이터가 아닌 자료구조에 대해서도 자료 순회가 가능하도록 구현하기위한 인터페이스.. 반복을 위한 IEnumerator 를 상속받는 클래스를 구현하고, Collection 이 IEnumerable 을 상속받은 후, IEnumerable 의 멤버인 GetEnumerator() 에서 IEnumerator를 상속받은 클래스의 객체를 생성해서 리턴하는 형태로 작성한다. 다음은 IEnumerable 를 상속받는 ILi..
2022.07.15 -
[Playfab] A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
"A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details." Or "IndexOutOfRangeException: Index was outside the bounds of the array." This error usually occurs when you import Playfab SDK package to unity and play at the very first time. If you got first error message , maybe your UnityEditor version is higher then 2020 LTS version. To so..
2022.02.11 -
Unity DOTS - how to check entity is null.
Normally , We check entity is null or not with EntityManager. Unity documents and also many of developers explaine like this way Accessing to entityManager to check if entity is null. So when you want to check all entities are null, then you have to access entityManager many times in for loop. However, when you take a look the Entity class, Entity includes Null static variable. So, at first, I d..
2021.08.07