일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- 픽셀
- javascript
- euler
- 회전
- 2D
- Unity
- intervals
- addEventListener
- Quaternion
- click
- className
- classList
- vsCode
- 도린이
- Event
- jQuery
- 종속변수
- PYTHON
- 탑다운
- 자주 사용하는 Quaternion 함수
- 코딩
- wsl
- Lerp
- 독립변수
- 연습
- setItem
- 도트
- 웹스크래핑
- getItem
- topdown
- Today
- Total
쫑가 과정
2D sorting / 2d 오브젝트 렌더러 우선순위 정하기. 본문
https://docs.unity3d.com/kr/current/Manual/2DSorting.html
2D 정렬 - Unity 매뉴얼
Unity는 타입과 용도에 기반한 우선 순위에 따라 렌더러를 정렬합니다. 렌더러 대기열을 통해 렌더러의 렌더 순서를 지정할 수 있습니다. 일반적으로 두 가지 메인 대기열, 즉 불투명 대기열과 투
docs.unity3d.com
쉬운 방법으로 해보자.
1. Sorting Group
https://docs.unity3d.com/kr/current/Manual/class-SortingGroup.html
정렬 그룹 - Unity 매뉴얼
정렬 그룹 을 사용하면 그룹 게임 오브젝트를 스프라이트 렌더러와 함께 그룹화하고, 해당 스프라이트를 렌더링하는 순서를 제어할 수 있습니다. Unity는 스프라이트 렌더러를 동일한 정렬 그룹
docs.unity3d.com
사용 방법.
1. Sorting Layer 설정
Sorting Layer설정 내 해당 위치를 기준으로 순서를 결정하고, 리스트에 표시되는 순서로 Sorting Layer를 렌더링.
정렬 레이어 설정에 대한 자세한 내용은 태그 및 레이어를 참조.
위에서 아래로 우선순위가 결정된다.
Ground > Seleted > Default > Player > Tree
2. Order in Layer 설정
Sorting Layer 내에서 이 정렬 그룹의 렌더링 순서를 설정.
값이 가장 낮은 렌더러를 렌더링 대기열에 먼저 넣어 값이 높은 렌더러보다 먼저 표시되도록 만듦.
2. 카메라까지의 거리
1. Edit -> Project Setting -> Graphics -> Camera Settings 아래에서 Transparent Sort.
선택한 카메라 모드(Perspective 또는 Orthographic)에 맞게 카메라의 TransparencySortMode를 자동으로 설정.
구현 목표에 따라 Sort Mode를 설정한다.
나무 뒤에 플레이어가 보이고 싶지 않다.
Transparency Sort Mode를 Custom Axis로 변경하고 Y축을 렌더링 하고자 Axis를 Y축 1로 설정한다.
중요! 정상적으로 적용되기 위해서는 Sorting Layer가 같아야 한다. 저는 둘 다 Default로 설정
나무 뒤로 숨을 수 있게 되었지만 뭔가 잘 숨어지지 않는다.
1. Sprite Sort Point
2. Pivot 설정
Sprite 파일에서 설정해야 함.

나무와 플레이어의 Pivot을 하단 중앙으로 설정하고 다시 테스트.
2. 스크립팅 API를 통해 카메라의 TransparencySortMode를 설정.
https://docs.unity3d.com/2020.3/Documentation/ScriptReference/TransparencySortMode.html
Unity - Scripting API: TransparencySortMode
By default, perspective cameras sort objects based on distance from camera position to the object center; and orthographic cameras sort based on distance along the view direction. If you're making a 2D game with a perspective camera, you might want to use
docs.unity3d.com
public class MouseInput : MonoBehaviour
{
public Camera mainCamera;
private void Update()
{
if (Input.GetMouseButtonDown(1))
{
if(mainCamera.transparencySortMode == TransparencySortMode.CustomAxis)
{
mainCamera.transparencySortMode = TransparencySortMode.Default;
Debug.Log(mainCamera.transparencySortMode);
}
else
{
mainCamera.transparencySortMode = TransparencySortMode.CustomAxis;
Debug.Log(mainCamera.transparencySortMode);
}
}
}
'Unity2D > 구현' 카테고리의 다른 글
적 AI. 플레이어 따라가기. (0) | 2022.02.03 |
---|---|
2d 클릭 2) 더블 클릭 (0) | 2022.01.26 |
2d 클릭 1) 오브젝트 클릭 (0) | 2022.01.24 |