docs.unity3d.com
    Show / Hide Table of Contents

    Property BuildPath

    BuildPath

    The build path used by the Addressables system for its initialization data.

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

    Addressables.BuildPath returns the path used by the Addressables system for its built initialization data. This path is to the Addressables folder in the Project Library folder for the active platform.This folder contains the settings, local catalog and addressables managed local asset bundles.

    Examples

    Gets the runtime settings from the buildPath and returns the Addressables package version that the content was built using.

          public string GetBuiltContentAddressablesVersion()
    {
    string settingsPath = Addressables.BuildPath + "/settings.json";
    if (System.IO.File.Exists(settingsPath))
    {
    string json = System.IO.File.ReadAllText(settingsPath);
    ResourceManagerRuntimeData activeRuntimeSettings =
        JsonUtility.FromJson<ResourceManagerRuntimeData>(json);
    return activeRuntimeSettings.AddressablesVersion;
    }
    return null;
    }

    In this example we add a build pre-process hook. When building a player this throws an exception if the content has not been built. This could be useful when 'Build Addressables on Player Build' is not set in Addressables Settings.

    #if UNITY_EDITOR
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using UnityEditor.AddressableAssets;
    using UnityEditor.AddressableAssets.Build;
    using UnityEditor.AddressableAssets.Settings.GroupSchemas;
    using UnityEditor.Build;
    using UnityEditor.Build.Reporting;
    using UnityEngine;
    using UnityEngine.AddressableAssets;
    
    public class ContentBuiltCheck : IPreprocessBuildWithReport
    {
    public int callbackOrder => 1;
    
    public void OnPreprocessBuild(BuildReport report)
    {
        // we don't want to throw the exception in our continuous integration environment
        if (Application.isBatchMode)
        {
            return;
        }
        var settingsPath = Addressables.BuildPath + "/settings.json";
        if (!File.Exists(settingsPath))
        {
            throw new System.Exception("Player content has not been built. Aborting build until content is built. This can be done from the Addressables window in the Build->Build Player Content menu command.");
        }
    }
    }
    #endif
    Back to top Copyright © 2023 Unity Technologies
    Generated by DocFX
    on Tuesday, March 14, 2023
    Terms of use