docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Build with continuous integration

    You can integrate Addressables into your continuous integration (CI) to perform content builds across different environments and team members. When integrating Addressables in CI, consider the following:

    • Content builder configuration: Set up the correct builder for the CI process.
    • Cache management: Clear cached data to prevent build inconsistencies.
    • Pipeline optimization: Manage the Scriptable Build Pipeline cache for clean builds.

    Configure custom content builders

    Addressables uses content builders to process and package your project's assets. The system defaults to BuildScriptPackedMode when you call AddressableAssetSettings.BuildPlayerContent. This method automatically uses the ActivePlayerDataBuilder setting and executes that builder's BuildDataImplementation.

    Setting up custom builders for continuous integration

    If you have implemented a custom IDataBuilder for CI builds, you need to specify which builder to use:

    1. Set the ActivePlayerDataBuilderIndex property on the AddressableAssetSettings instance.
    2. Access the settings through AddressableAssetSettingsDefaultObject.Settings.
    3. Use the index that corresponds to thr custom builder's position in the DataBuilders list.

    The following code example demonstrates how to configure a custom builder:

    
    #if UNITY_EDITOR
        using UnityEditor.AddressableAssets;
        using UnityEditor.AddressableAssets.Build;
        using UnityEditor.AddressableAssets.Settings;
        using UnityEngine;
    
        internal class CustomDataBuilder
        {
            public static void SetCustomDataBuilder(IDataBuilder builder)
            {
                AddressableAssetSettings settings
                    = AddressableAssetSettingsDefaultObject.Settings;
    
                int index = settings.DataBuilders.IndexOf((ScriptableObject)builder);
                if (index > 0)
                    settings.ActivePlayerDataBuilderIndex = index;
                else if (AddressableAssetSettingsDefaultObject.Settings.AddDataBuilder(builder))
                    settings.ActivePlayerDataBuilderIndex
                        = AddressableAssetSettingsDefaultObject.Settings.DataBuilders.Count - 1;
                else
                    Debug.LogWarning($"{builder} could not be found " +
                                     $"or added to the list of DataBuilders");
            }
        }
    #endif
    
    

    Clean the Addressables content builder cache

    Cache cleaning prevents CI builds from using outdated files from previous builds, which can cause inconsistent or incorrect build results.

    Each IDataBuilder implementation includes a ClearCachedData method that removes files created by that specific builder. For the default BuildScriptPackedMode, this includes:

    • Content catalog files.
    • Serialized settings files.
    • Built AssetBundles.
    • Generated link.xml files.

    Call IDataBuilder.ClearCachedData as part of your CI process to ensure clean builds that don't rely on artifacts from previous runs.

    Clean the scriptable build pipeline cache

    The Scriptable Build Pipeline (SBP) creates a build cache in the Library/BuildCache folder to optimize subsequent builds. This cache contains:

    • .info files with build metadata.
    • Hash maps for tracking asset changes.
    • Type database information.

    While this cache speeds up development builds by reusing unchanged data, it can cause issues in CI environments where you need completely clean builds.

    Call BuildCache.PurgeCache(false) in your build scripts to clear the SBP cache. The false parameter skips the confirmation dialog.

    Platform considerations

    When building for multiple platforms in CI, restart Unity for each platform. This ensures that Unity completes script compilation for each target platform before executing build methods via -executeMethod.

    Platform switches can trigger domain reloads and script recompilation. If you don't wait for these processes to complete, your build methods might execute with the wrong platform settings or incomplete compilation.

    For more information, refer to the Unity User Manual documentation on Command line arguments.

    Additional resources

    • Command line arguments
    • Build output
    • IDataBuilder API reference
    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)