모든 게임 오브젝트는 단일 레이어에 존재하지만 API가 영향을 미치는 레이어를 설정할 수 있는 Unity API는 레이어를 직접 사용하지 않습니다. 대신 레이어마스크를 사용합니다.
레이어는 표준 정수이지만 레이어마스크는 비트마스크로 포맷한 정수입니다. 여기서 모든 1
은 포함할 레이어를 나타내고 모든 0
은 제외할 레이어를 나타냅니다. 즉 레이어마스크를 예상하는 API에 레이어를 전달할 수 있고 레이어와 레이어마스크는 동일한 기본 타입을 사용하기 때문에 스크립트가 계속 컴파일됩니다. 그러나 API 호출은 예상한 동작을 생성하지 않습니다.
예를 들어 레이어 9에 있는 게임 오브젝트에 대해 레이캐스트를 수행하려는 경우 9
를 레이어마스크로 Physics.Raycast 호출에 전달하면 실제로는 Unity에서 레이어 3
과 레이어 0
의 게임 오브젝트에 대해 레이캐스트를 수행합니다. 9의 이진법 표기는 00001001
이고 이를 마스크로 해석하면 3
과 0
자리에 1
이 있기 때문입니다.
API 호출에 사용할 레이어마스크를 설정하는 방법에 대한 자세한 내용은 레이어마스크 설정을 참조하십시오.
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.