Unity의 렌더러는 레이어 순서나 카메라로부터의 거리 등 몇 가지 기준에 따라 정렬됩니다.Unity의 Graphics 설정(메뉴:Edit > Project Settings > Graphics)에는 Transparency Sort Mode라는 설정이 있으며, 이를 사용하여 카메라에 대한 스프라이트의 포지션에 따라 스프라이트를 정렬하는 방식을 제어할 수 있습니다.더 구체적으로 말하자면, 축에서 스프라이트의 포지션을 사용해 다른 스프라이트와 비교하여 어떤 스프라이트가 투명한지 결정합니다.
예를 들어 이 설정은 스프라이트를 y축을 따라 정렬하는 경우 사용할 수 있습니다.이 설정은 2D 게임에서 더 높이 있는 스프라이트가 더 낮은 스프라이트 뒤에 정렬되어 더 멀리 있는 것처럼 보이게 하는 데 많이 사용됩니다.
다음 네 가지 Transparency Sort Mode 옵션을 사용할 수 있습니다.
Sort Mode | 설명 |
---|---|
Default | 카메라의 투사 모드 설정이 Perspective인지 또는 Orthographic인지에 따라 정렬합니다. |
Perspective | 원근 뷰에 따라 정렬합니다.원근 뷰는 카메라 위치에서 스트라이트 중심까지의 거리를 기준으로 스프라이트를 정렬합니다. |
Orthographic | 직교 뷰에 따라 정렬합니다.직교 뷰는 뷰 방향에 따른 거리를 기준으로 스프라이트를 정렬합니다. |
Custom Axis | Transparency Sort Axis에서 설정한 특정 축을 기준으로 정렬합니다. |
Transparency Sort Mode를 Custom Axis로 설정한 경우 Transparency Sort Axis도 설정해야 합니다.
Transparency Sort Mode를 Custom Axis로 설정한 경우 씬 뷰의 렌더러가 이 축과 카메라의 거리를 기준으로 정렬됩니다.축은 –1과 1 사이의 값을 사용하여 정의합니다.예시:X=0, Y=1, Z=0이면 축 방향이 위쪽으로 설정됩니다.X=1, Y=1, Z=0이면 축이 X와 Y 사이의 대각선 방향으로 설정됩니다.
예를 들어 스프라이트가 위 이미지에서 처럼 동작하게 만들고 싶다면 Transparency Sort Mode를 Custom Axis로 설정하고 Transparency Sort Axis의 Y 값을 0보다 크게 설정하십시오.
스크립트를 통해 카메라의 다음 프로퍼티를 수정하여 카메라를 기준으로 스프라이트를 정렬할 수도 있습니다.
TransparencySortMode(Transparency Sort Mode에 해당)
TransparencySortAxis(Transparency Sort Axis에 해당)
예제:
var camera = GetComponent<Camera>();
camera.transparencySortMode = TransparencySortMode.CustomAxis;
camera.transparencySortAxis = new Vector3(0.0f, 1.0f, 0.0f);
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.