Version: Unity 6.0 (6000.0)
언어 : 한국어
네임스페이스 접두사 정의
요소 관리를 위한 베스트 프랙티스

Troubleshooting custom control library compilation

This troubleshooting guide helps you resolve issues when compiling custom controls into DLLs.

Symptoms

When you compile custom controls into DLLs, you might encounter the following issues:

  • Custom controls don’t appear in the__ UI__(사용자 인터페이스) 사용자가 애플리케이션과 상호 작용하도록 해 줍니다. Unity는 현재 3개의 UI 시스템을 지원합니다. 자세한 정보
    See in Glossary
    Builder.
  • Custom controls don’t serialize correctly when building libraries (DLLs).

Cause

UI Toolkit uses the UxmlElement code generator to support UXML serialization. However, when compiling custom controls into DLLs, the generated serialization code isn’t included by default, causing issues with element visibility and serialization.

Resolution

To resolve this issue, run the UI Toolkit source generator (Unity.UIToolkit.SourceGenerator.dll) during the DLL compilation process.

  1. Find the source generator file in your Unity installation. It’s typically located at: <Unity Installation Path>\Data\Tools\Unity.SourceGenerators\Unity.UIToolkit.SourceGenerator.dll.

  2. Add the source generator as an analyzer in your library project’s .csproj file within an <ItemGroup>:

    <ItemGroup>
        <Analyzer Include="path\to\Unity.UIToolkit.SourceGenerator.dll" />
    </ItemGroup>
    
  3. Compile your library as usual. This triggers the source generator, which generates the required UxmlSerializedData class for your custom control.

Tip: Always rebuild your library against the Unity version you’re using because the generated code might vary between versions.

Additional resources

네임스페이스 접두사 정의
요소 관리를 위한 베스트 프랙티스
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961