큰 메시를 테셀레이션할 때 성능을 개선하려면 잡 시스템을 사용합니다. 그러면 메인 스레드가 장시간 차단되는 것을 방지할 수 있습니다. 테셀레이션 잡을 생성할 때 MeshGenerationContext.AddMeshGenerationJob API를 사용하여 UI 툴킷에 잡 핸들을 제공합니다. 이렇게 하면 UI 툴킷이 잡이 완료될 때까지 기다렸다가 메시에 액세스할 수 있습니다.
버텍스 또는 인덱스의 수를 빠르게 계산할 수 있다면 메인 스레드를 사용하여 메시를 할당하고 드로우 시퀀스에 추가할 수 있습니다. 다음 API를 사용하여 이를 수행할 수 있습니다.
참고: generateVisualContent를 호출하는 동안 언제든지 드로우 시퀀스에 메시를 추가할 수 있습니다.
다음 예시는 잡이 실제 테셀레이션을 수행하는 메인 스레드에 할당된 잡 시스템을 위한 테셀레이션을 보여 줍니다.
[!code-cs[(Modules/UIElements/Tests/UIElementsExamples/Assets/Examples/MeshGenerationContext_AddMeshGenerationJob.cs)]
버텍스 또는 인덱스 수를 계산하는 데 비용이 많이 드는 경우 MeshGenerationNode를 드로우 시퀀스에 삽입합니다. 그런 다음 TempMeshAllocator와 함께 노드를 잡에 제공합니다. 다음 API를 사용하여 이를 수행할 수 있습니다.
이 접근 방식에서는 잡에서 할당을 수행합니다. TempMeshAllocator.AllocateTempMesh를 사용하여 잡에서 일시적 메시를 안전하게 할당합니다. MeshGenerationNode.DrawMesh는 잡에 의해 채워지는 중첩된 드로우 시퀀스의 컨테이너처럼 작동합니다.
다음은 이전 예시를 기반으로 잡에서 할당과 테셀레이션을 모두 수행하는 방법을 보여 줍니다.
[!code-cs[(Modules/UIElements/Tests/UIElementsExamples/Assets/Examples/MeshGenerationContext_InsertMeshGenerationNode.cs)]
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.