docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Preprocessor directives

    Note

    PMDT supports multiple methods of specifying .NET API code project(s) for DocFX to analyse and extract API documentation, which supply different preprocessor constants by default.

    If you have code inside a preprocessor directive (for example, #if MY_CONSTANT <code> #endif) and you want this code to have its API documented, you can use the Package Manager Doc Tools (PMDT) preprocessor directives to make sure that it generates documentation for these APIs.

    PMDT adds the PACKAGE_DOCS_GENERATION directive to all generated code projects submitted to DocFX when it generates the API documentation, so you can add this to your code (for example, #if MY_CONSTANT || PACKAGE_DOCS_GENERATION <code> #endif).

    Or, you can tell PMDT which preprocessor directives to enable when it generates the documentation.

    For both code project generation methods, specify additional preprocessor directives in package metadata.

    For backwards compatibility and for monolithic code project generation only, create a config.json file inside the Documentation~ folder with a DefineConstants string property. For example:

    { "DefineConstants": "MY_CONSTANT;MY_OTHER_CONSTANT" }
    
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)