docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Property PlayerBuildDataPath

    PlayerBuildDataPath

    The path that addressables player data gets copied to during a player build.

    Declaration
    public static string PlayerBuildDataPath { get; }
    Property Value
    Type Description
    string
    Remarks

    This resolves to Assets/StreamingAssets/aa by default. Files in this folder are included in the player build process. Remote bundles should be built outside this folder to prevent them from being included in the default player build.

    Examples

    This example is a custom build script that extends the default packed build script. Files are built in a custom build folder, and then copied into PlayerBuildDataPath so they are included with the player build.

    using System.IO;
    using UnityEditor;
    using UnityEditor.AddressableAssets.Build;
    using UnityEditor.AddressableAssets.Build.DataBuilders;
    using UnityEditor.AddressableAssets.Settings;
    using UnityEngine;
    using UnityEngine.AddressableAssets;
    

    [CreateAssetMenu(fileName = "CustomLocationBuildScript.asset", menuName = "Addressables/Custom Build/Custom Location Build Script")] public class CustomLocationBuildScript : BuildScriptPackedMode {

    // BuildPath is set to [CustomLocationBuildScript.CustomLocationBuildRoot]/SpecialGroup/[BuildTarget]
    // LoadPath is set to {UnityEngine.AddressableAssets.Addressables.PlayerBuildDataPath}/SpecialGroup/[BuildTarget]
    public static string CustomLocationBuildRoot
    {
        get { return "CustomBuildPath"; }
    }
    
    public override string Name
    {
        get { return "Custom Location Build Script"; }
    }
    
    protected override TResult BuildDataImplementation<TResult>(AddressablesDataBuilderInput context)
    {
        var result = base.BuildDataImplementation<TResult>(context);
    
        AddressableAssetSettings settings = context.AddressableSettings;
        CopyBundles(settings);
        return result;
    }
    
    void CopyBundles(AddressableAssetSettings settings)
    {
    
        // if the PlayerBuildDataPath does not exist, create it
        var streamingAssetsPath = Addressables.PlayerBuildDataPath;
        if (!Directory.Exists(streamingAssetsPath))
        {
            Directory.CreateDirectory(streamingAssetsPath);
        }
    
        // Copy all directories from the CustomLocationBuildRoot to the PlayerBuildDataPath
        var directories = Directory.GetDirectories(CustomLocationBuildRoot);
        foreach (var directory in directories)
        {
            var fileName = Path.GetFileName(directory);
            FileUtil.ReplaceFile($"{CustomLocationBuildRoot}/{fileName}", $"{streamingAssetsPath}/{fileName}");
        }
    }
    

    }

    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)