docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Use reference image libraries with AssetBundles

    Understand how to package a reference image library into an AssetBundle.

    To include a reference image library in an AssetBundle, AR Foundation requires that you first call ARBuildProcessor.PreprocessBuild before you build AssetBundles. Platform-specific data is attached to XRReferenceImageLibrary assets during this preprocessor step.

    Refer to the following sample code to understand how to build AssetBundles that contain reference image libraries:

    static void ExportAssetBundles(string directoryPath, BuildTarget buildTarget)
    {
        UnityEditor.XR.ARSubsystems.ARBuildProcessor.PreprocessBuild(buildTarget);
        BuildPipeline.BuildAssetBundles(
            directoryPath,
            BuildAssetBundleOptions.ForceRebuildAssetBundle,
            buildTarget);
    }
    

    Build AssetBundles window

    Alternatively, you can use the Build AssetBundles window, located at Assets > AR Foundation > Build AssetBundles, to export your AssetBundles to the chosen directory.

    Build AssetBundles window shown in the Editor
    Build AssetBundles window.

    The following table describes the fields in the Build AssetBundles window:

    Element Description
    Build for Target Specifies the target platform for the AssetBundles.
    Output Directory The directory in which to save the built AssetBundles. You can either type this into the text field or click the folder icon to open a file picker.
    Clean Output Directory If enabled, all files in the output directory will be deleted before the AssetBundles are built.
    Build AssetBundles Build the AssetBundles to the chosen directory.
    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)