docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Custom build scripting

    To configure a new custom script, add it to the Build and Play Mode Scripts list.

    Custom scripts extend the BuildScriptBase class or implement the IDataBuilder interface. There are several methods that you can override, such as ClearCachedData and CanBuildData<T>. If extending the BuildScriptBase class, the most notable method to override is BuildDataImplementation<TResult>. This is the method that's used to setup or build content.

    A custom script is either a Build Script or a Play Mode Script. This is determined by how the CanBuildData<T> method is implemented. Build scripts can only build data of the type AddressablesPlayerBuildResult, so the method is implemented in this way:

    
    public override bool CanBuildData<T>()
    {
        return typeof(T).IsAssignableFrom(typeof(AddressablesPlayerBuildResult));
    }
    
    

    This allows the script to be listed in the Build menu.

    Play Mode Scripts can only build data of the type AddressablesPlayModeBuildResult, so the method is implemented in this way:

    
    public override bool CanBuildData<T>()
    {
        return typeof(T).IsAssignableFrom(typeof(AddressablesPlayModeBuildResult));
    }
    
    

    This allows the script to be listed in the Play Mode Scripts menu.

    See the Custom Build and Play Mode Scripts Sample for an example.

    Extend the default build script

    If you want to use the same basic build as the default build script BuildScriptPackedMode, but want to treat specific groups or types of assets differently, you can extend and override the default build script. If the group or asset the build script is processing is one that you want to treat differently, you can run your own code. Otherwise, you can call the base class version of the function to use the default algorithm.

    Refer to the Addressable variants project for an example.

    Save the content state

    If you support remote content distribution and update your content between player releases, you must record the state of your Addressables groups at the time of the build. Recording the state lets you perform a differential build using the Update a Previous Build script.

    Refer to the implementation of BuildScriptPackedMode and ContentUpdateScript for details.

    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)