### Instantiate ContentCatalogProvider - C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.ResourceProviders This snippet demonstrates how to instantiate the ContentCatalogProvider. It requires a ResourceManager instance to be passed to its constructor. This is a basic setup for initializing the provider. ```csharp using UnityEngine.AddressableAssets.ResourceProviders; // Assuming you have a ResourceManager instance available ResourceManager resourceManager = new ResourceManager(); // Instantiate the ContentCatalogProvider ContentCatalogProvider catalogProvider = new ContentCatalogProvider(resourceManager); ``` -------------------------------- ### Addressables.InitializeAsync API Reference Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/InitializeAsync This snippet details the Addressables.InitializeAsync API, used for initializing the Addressables system asynchronously. It's crucial for setting up asset management before loading addressable assets. No specific input/output is detailed, but it's a core setup function. ```csharp public static AsyncOperationHandle InitializeAsync (AddressablesData data = null); public static AsyncOperationHandle InitializeAsync (string address = null); public static AsyncOperationHandle InitializeAsync (); ``` -------------------------------- ### Construct AddressableAssetsBundleBuildParameters Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.DataBuilders.AddressableAssetsBundleBuildParameters Initializes AddressableAssetsBundleBuildParameters with settings for bundle compression and build configuration. Requires AddressableAssetSettings, a dictionary mapping bundle identifiers to asset group GUIDs, the build target and group, and the output folder path. ```csharp public AddressableAssetsBundleBuildParameters(AddressableAssetSettings aaSettings, Dictionary bundleToAssetGroup, BuildTarget target, BuildTargetGroup group, string outputFolder) ``` -------------------------------- ### Unity Command Line Execution for Batch Builds (Shell) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/build-scripting-recompiling Examples of how to execute the C# batch build script functions using Unity's command-line interface. These commands allow for automated builds and configuration changes without opening the Unity Editor interactively. ```shell D:\Unity\2020.3.0f1\Editor\Unity.exe -quit -batchMode -projectPath . -executeMethod BatchBuild.ChangeSettings -defines=FOO;BAR -buildTarget Android D:\Unity\2020.3.0f1\Editor\Unity.exe -quit -batchMode -projectPath . -executeMethod BatchBuild.BuildContentAndPlayer -buildTarget Android ``` -------------------------------- ### Unity Editor - Example Variable Syntax Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/ProfileVariables Demonstrates how to use profile variables with bracket syntax for build-time evaluation in Unity's Addressables system. This syntax allows referencing static properties or other variables that are resolved during the build process. ```csharp // Example of a load path using build-time evaluated variables // '{MyNamespace.MyClass.MyURL}/content/[BuildTarget]' // Example code demonstrating direct use of UnityEditor properties (for context within Editor scripts): string buildTargetString = "[UnityEditor.EditorUserBuildSettings.activeBuildTarget]"; // This string would be evaluated by Addressables during build time. ``` -------------------------------- ### Preload Multiple Prefab Assets by Label in Unity Addressables Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/GetRuntimeAddress This C# coroutine example shows how to load multiple prefab assets associated with a specific label ('SpaceHazards') using Unity Addressables. It first loads the resource locations, then asynchronously loads each asset, stores them in a dictionary using their primary key, and finally logs the preloaded assets. This pattern is useful for efficient asset management and reducing loading times. ```csharp Dictionary _preloadedObjects = new Dictionary(); private IEnumerator PreloadHazards() { //find all the locations with label "SpaceHazards" var loadResourceLocationsHandle = Addressables.LoadResourceLocationsAsync("SpaceHazards", typeof(GameObject)); if (!loadResourceLocationsHandle.IsDone) yield return loadResourceLocationsHandle; //start each location loading List opList = new List(); foreach (IResourceLocation location in loadResourceLocationsHandle.Result) { AsyncOperationHandle loadAssetHandle = Addressables.LoadAssetAsync(location); loadAssetHandle.Completed += obj => { _preloadedObjects.Add(location.PrimaryKey, obj.Result); }; opList.Add(loadAssetHandle); } //create a GroupOperation to wait on all the above loads at once. var groupOp = Addressables.ResourceManager.CreateGenericGroupOperation(opList); if (!groupOp.IsDone) yield return groupOp; loadResourceLocationsHandle.Release(); //take a gander at our results. foreach (var item in _preloadedObjects) { Debug.Log(item.Key + " - " + item.Value.name); } } ``` -------------------------------- ### GET /websites/unity3d_packages_com_unity_addressables_2_7/Dependencies Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceLocations.ResourceLocationBase Retrieves the list of dependencies that must be loaded before a specific resource location. This information is crucial for managing asset loading order and ensuring all required assets are available. ```APIDOC ## GET /websites/unity3d_packages_com_unity_addressables_2_7/Dependencies ### Description Retrieves the list of dependencies that must be loaded before this location. This value may be null. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_addressables_2_7/Dependencies ### Parameters #### Query Parameters N/A #### Path Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Dependencies** (IList) - A list of `IResourceLocation` objects representing the dependencies. This can be null if there are no dependencies. #### Response Example ```json { "Dependencies": [ { "Id": "some_dependency_id_1", "Resource": "path/to/dependency1.asset" }, { "Id": "some_dependency_id_2", "Resource": "path/to/dependency2.asset" } ] } ``` #### Error Response (404) - **message** (string) - Error message indicating the resource location was not found. ``` -------------------------------- ### Load Asset via AssetReference Async Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/LoadingAssetReferences This C# script demonstrates how to load an asset asynchronously using an AssetReference. It assigns an asset in the editor, starts the load operation on `Start`, instantiates the asset upon successful completion, and releases the asset when the GameObject is destroyed. Dependencies include UnityEngine and UnityEngine.AddressableAssets. ```csharp using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; internal class LoadFromReference : MonoBehaviour { // Assign in Editor public AssetReference reference; // Start the load operation on start void Start() { AsyncOperationHandle handle = reference.LoadAssetAsync(); handle.Completed += Handle_Completed; } // Instantiate the loaded prefab on complete private void Handle_Completed(AsyncOperationHandle obj) { if (obj.Status == AsyncOperationStatus.Succeeded) { Instantiate(reference.Asset, transform); } else { Debug.LogError("AssetReference failed to load."); } } // Release asset when parent object is destroyed private void OnDestroy() { reference.ReleaseAsset(); } } ``` -------------------------------- ### Unity Runtime - Example Variable Syntax Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/ProfileVariables Illustrates the use of profile variables with brace syntax for runtime evaluation in Unity's Addressables system. This enables referencing properties or variables that are resolved dynamically when the application is running. ```csharp // Example of a load path using run-time evaluated variables // '{UnityEngine.AddressableAssets.Addressables.RuntimePath}/content/[BuildTarget]' // Example code demonstrating direct use of Addressables runtime properties (for context within runtime scripts): string runtimePath = "{UnityEngine.AddressableAssets.Addressables.RuntimePath}"; // This string would be evaluated by Addressables at runtime. ``` -------------------------------- ### OnPrebuild Method Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.AddressablesBuildMenuUpdateAPreviousBuild This method is invoked before the Addressables content build process starts. It takes an AddressablesDataBuilderInput object and returns a boolean indicating success or failure. ```APIDOC ## OnPrebuild ### Description Called before beginning the Addressables content build. ### Method `virtual bool OnPrebuild(AddressablesDataBuilderInput input)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body example available." } ``` ### Response #### Success Response (200) - **bool** (bool) - True for success, else false and fail the build #### Response Example ```json { "example": "true" } ``` ### Error Handling - If the method returns `false`, the build will fail. ``` -------------------------------- ### Custom Build and Play mode Scripts: CustomPlayModeScript (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/SamplesOverview Implements custom build and play mode scripts for the Addressables package. The custom play mode script functions similarly to the 'Use Existing Build' script, allowing for custom setup and reversion of the current scene. Requires Unity's Addressables package. ```csharp using UnityEngine; using UnityEditor; using UnityEditor.AddressableAssets.Build; using UnityEditor.AddressableAssets.Settings; using System.Collections.Generic; public class CustomPlayModeScript : ICustomPlayModeScript { public void CreateCurrentSceneOnlyBuildSetup(AddressableAssets.Settings.AddressableAssetSettings settings) { Debug.Log("Creating build setup for the current scene in Play mode."); // Logic to prepare the environment for playing with only the current scene. // This might involve ensuring necessary assets are available locally or simulating a build. // Placeholder for actual implementation details } public void RevertCurrentSceneSetup(AddressableAssets.Settings.AddressableAssetSettings settings) { Debug.Log("Reverting current scene setup after Play mode."); // Logic to clean up any changes made during the custom play mode setup. // Placeholder for actual implementation details } // Methods required by ICustomPlayModeScript interface would be implemented here. // For example, methods to handle asset loading and unloading in custom play mode. } ``` -------------------------------- ### Addressables Build Script - CanBuildData Example Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/build-scripting-custom This C# code snippet demonstrates how to implement the `CanBuildData` method for a build script in Unity Addressables. It ensures that the script can only build data of the type `AddressablesPlayerBuildResult`, making it appear in the 'Build' menu. ```csharp public override bool CanBuildData() { return typeof(T).IsAssignableFrom(typeof(AddressablesPlayerBuildResult)); } ``` -------------------------------- ### PrepareForBuild Method Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/Global-Namespace.AddressablesPlayerBuildProcessor Details of the PrepareForBuild method, including its purpose, declaration, parameters, and overrides. ```APIDOC ## PrepareForBuild Method ### Description Invoked before performing a Player build. Maintains building Addressables step and processing Addressables build data. ### Method PrepareForBuild ### Endpoint N/A (This is a C# method, not a REST API endpoint) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) This method has a void return type and does not return any data. #### Response Example N/A ``` -------------------------------- ### Accessing AddressableAssetGroup Guid - C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.Layout.BuildLayout.Group This C# snippet demonstrates how to access the Guid property of an AddressableAssetGroup object. The Guid property returns a string representing the unique identifier of the group. ```csharp using UnityEditor.AddressableAssets.Build.Layout; // Assuming 'addressableAssetGroup' is an instance of AddressableAssetGroup string groupGuid = addressableAssetGroup.Guid; ``` -------------------------------- ### Create BuildLayoutParameters with Bundle Remapping and Catalog Data (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.DataBuilders.BuildLayoutParameters This snippet shows how to instantiate BuildLayoutParameters with both bundle name remapping and ContentCatalogData. Including ContentCatalogData allows for more specific control over the catalog used during the build, which is essential for complex Addressables setups. It requires System.Collections.Generic and UnityEditor.AddressableAssets.Build namespaces. ```csharp using System.Collections.Generic; using UnityEditor.AddressableAssets.Build; using UnityEditor.AddressableAssets.Settings.DataBuilders; // ... Dictionary bundleNameRemap = new Dictionary() { { "internal_bundle_name", "file_name.bundle" } }; ContentCatalogData catalogData = new ContentCatalogData(); // Replace with actual ContentCatalogData initialization BuildLayoutParameters layoutParameters = new BuildLayoutParameters(bundleNameRemap, catalogData); ``` -------------------------------- ### Method ProvideInstance Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider Provides an instance of a loaded GameObject using the ResourceManager, a prefab handle, and instantiation parameters. ```APIDOC ## POST /websites/unity3d_packages_com_unity_addressables_2_7/ProvideInstance ### Description Provides an instance of a loaded GameObject from a given prefab handle and instantiation parameters. ### Method POST ### Endpoint /websites/unity3d_packages_com_unity_addressables_2_7/ProvideInstance ### Parameters #### Request Body - **resourceManager** (ResourceManager) - Required - The resource manager to use for instantiation. - **prefabHandle** (AsyncOperationHandle) - Required - The operation handle containing the reference to the GameObject prefab to instantiate. - **instantiateParameters** (InstantiationParameters) - Required - Container for data specifying how to instantiate the GameObject. ### Request Example ```json { "resourceManager": "", "prefabHandle": "", "instantiateParameters": "" } ``` ### Response #### Success Response (200) - **GameObject** (GameObject) - The instantiated GameObject. #### Response Example ```json { "instance": "" } ``` ``` -------------------------------- ### Construct AssetReferenceTexture2D with GUID Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceTexture2D Creates a new reference to a Texture2D asset by providing its unique identifier (GUID). This is useful for referencing texture assets within the Addressables system. ```csharp public AssetReferenceTexture2D(string guid) { // Constructor implementation to create a reference to a Texture2D asset using its GUID. } ``` -------------------------------- ### Construct AssetReferenceGameObject with GUID Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceGameObject This C# code snippet demonstrates how to construct an AssetReferenceGameObject by passing its unique identifier (GUID) to the constructor. This is useful for referencing GameObjects within Unity's Addressables system. ```csharp public AssetReferenceGameObject(string guid) { // Constructor implementation to create a new reference to a GameObject using its GUID. } ``` -------------------------------- ### ProvideInstance Method for GameObject Instantiation - C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider This C# method, ProvideInstance, is used to create an instance of a loaded GameObject. It requires a ResourceManager for operations, an AsyncOperationHandle pointing to the prefab, and InstantiationParameters to control the instantiation process. It returns the instantiated GameObject. ```csharp public GameObject ProvideInstance(ResourceManager resourceManager, AsyncOperationHandle prefabHandle, InstantiationParameters instantiateParameters) { // Implementation details for instantiating the GameObject // This would typically involve using the resourceManager and prefabHandle // to get the loaded GameObject and then instantiating it based on instantiateParameters. return null; // Placeholder } ``` -------------------------------- ### Load Scene Additively with Addressables Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/LoadingScenes Loads an Addressable scene additively using `Addressables.LoadSceneAsync`. The scene is unloaded when the parent GameObject is destroyed. This example demonstrates basic scene loading and unloading with Addressables. ```csharp using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.SceneManagement; internal class LoadSceneByAddress : MonoBehaviour { public string key; // address string private AsyncOperationHandle loadHandle; void Start() { loadHandle = Addressables.LoadSceneAsync(key, LoadSceneMode.Additive); } void OnDestroy() { Addressables.UnloadSceneAsync(loadHandle); } } ``` -------------------------------- ### Use the Cloud Content Delivery Bundle Location Option Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/ccd-configure This section explains how to use the 'Bundle Location' option within Addressables profiles to publish content directly to a designated CCD bucket and badge, simplifying the setup process. ```APIDOC ## Use the Cloud Content Delivery Bundle Location option If your project uses the CCD service, you can set the profile's remote path pair to publish content to a designated bucket and badge. This feature requires the Content Delivery Management API package. To set up a profile variable to use the CCD AssetBundle location: 1. Open the Profile window (menu: **Window > Asset Management > Addressables > Profiles**). 2. Select the profile to change. 3. Change the **Remote** variable to use the **Cloud Content Delivery** **Bundle Location**. 4. Choose `Automatic (set using CcdManager)` or `Specify the Environment, Bucket, and Badge` option. The `CcdManager` is a static class that is used to notify Addressables which Environment, Bucket, and Badge to load from at runtime. 5. Choose the Bucket to use. If no buckets are present, a window opens where you can create a new one. 6. Choose the Badge. Make this the active profile when building content for delivery with CCD. ``` -------------------------------- ### WebRequestQueueOperation Constructors Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement Information on how to initialize a WebRequestQueueOperation object. ```APIDOC ## Constructors ### WebRequestQueueOperation(UnityWebRequest) Initializes and returns an instance of WebRequestQueueOperation. ``` -------------------------------- ### Construct AssetReferenceTexture3D using GUID (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceTexture3D This snippet shows how to construct an AssetReferenceTexture3D object in C#. It takes a string GUID as a parameter to uniquely identify the Texture3D asset. This is useful for managing and loading addressable assets within Unity. ```csharp public AssetReferenceTexture3D(string guid) { // Constructor implementation details } ``` -------------------------------- ### Construct AssetReferenceTexture with GUID - C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceTexture This C# code snippet demonstrates how to construct an AssetReferenceTexture object using a string GUID. This is useful for creating references to texture assets within the Unity Addressables system. ```csharp public AssetReferenceTexture(string guid) { // Constructor implementation } ``` -------------------------------- ### Access DuplicatedGroupGuid in C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.AnalyzeRules.CheckBundleDupeDependencies.CheckDupeResult This C# code snippet demonstrates how to access the DuplicatedGroupGuid field. This field is of type GUID and returns the identifier of the group that is causing a duplication error. No specific inputs are required, and the output is a GUID object. ```csharp using UnityEditor.AddressableAssets.Build.AnalyzeRules; // Assuming 'analyzerResult' is an instance of a class that has access to DuplicatedGroupGuid // For example, if DuplicatedGroupGuid is a public property of a class like 'AnalyzerResult' // GUID duplicatedGuid = analyzerResult.DuplicatedGroupGuid; // If DuplicatedGroupGuid is a static field or a property of a static class, the access would be different. // Example for a hypothetical static class: // GUID duplicatedGuid = SomeAnalyzerClass.DuplicatedGroupGuid; // The actual usage depends on the context where DuplicatedGroupGuid is accessed. // This is a placeholder to illustrate accessing a GUID property. ``` -------------------------------- ### Pre-download Dependencies with Unity Addressables (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/remote-content-predownload This script demonstrates how to pre-download dependencies for a given key using Unity Addressables. It first checks the download size and then initiates the download if necessary. The operation handle is released after the download is complete or failed. This is useful for ensuring content is available before it's needed, such as at application startup. ```csharp string key = "assetKey"; // Check the download size AsyncOperationHandle getDownloadSize = Addressables.GetDownloadSizeAsync(key); yield return getDownloadSize; //If the download size is greater than 0, download all the dependencies. if (getDownloadSize.Result > 0) { AsyncOperationHandle downloadDependencies = Addressables.DownloadDependenciesAsync(key); yield return downloadDependencies; if(downloadDependencies.Status == AsyncOperationStatus.Failed) Debug.LogError("Failed to download dependencies for " + key); // we need to release the download handle so the assets can be loaded downloadDependencies.Release(); } ``` -------------------------------- ### Initialize AssetDatabaseProvider with Default Constructor Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider This snippet shows how to create an instance of AssetDatabaseProvider using its default constructor. This is useful for basic initialization without specifying any delay. ```csharp public AssetDatabaseProvider() { } ``` -------------------------------- ### Get Asset Address using AssetReference in Unity Addressables Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/GetRuntimeAddress This C# code snippet demonstrates how to retrieve the primary key (address) of an asset assigned to an AssetReference object at runtime. It utilizes Addressables.LoadResourceLocationsAsync and checks the operation's status and results before logging the address. Ensure the Addressables package is imported and configured. ```csharp var opHandle = Addressables.LoadResourceLocationsAsync(MyRef1); yield return opHandle; if (opHandle.Status == AsyncOperationStatus.Succeeded && opHandle.Result != null && opHandle.Result.Count > 0) { Debug.Log("address is: " + opHandle.Result[0].PrimaryKey); } ``` -------------------------------- ### AddressableAssetsBundleBuildParameters Constructor Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.DataBuilders.AddressableAssetsBundleBuildParameters Creates an AddressableAssetsBundleBuildParameters object with the necessary data for determining bundle compression. ```APIDOC ## AddressableAssetsBundleBuildParameters Constructor ### Description Creates an AddressableAssetsBundleBuildParameters object with data needed to determine the correct compression per bundle. ### Method Constructor ### Endpoint N/A (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Assuming AddressableAssetSettings, Dictionary, BuildTarget, BuildTargetGroup are defined AddressableAssetsBundleBuildParameters params = new AddressableAssetsBundleBuildParameters( aaSettings, bundleToAssetGroup, target, group, outputFolder ); ``` ### Response #### Success Response (200) N/A (Constructor) #### Response Example N/A (Constructor) ``` -------------------------------- ### Get and Set Group Name in C# - Unity Addressables Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Settings.AddressableAssetGroup This C# code snippet demonstrates how to get and set the 'Name' property of a group within the Unity Addressables package. This property is of type string and is virtual, allowing for potential overrides in derived classes. It is essential for identifying and managing addressable groups. ```csharp public virtual string Name { get; set; } ``` -------------------------------- ### UnknownResourceProviderException Methods Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.Exceptions Methods of the UnknownResourceProviderException class. ```APIDOC ## UnknownResourceProviderException Methods ### ToString() (string) - Returns string representation of exception. ``` -------------------------------- ### AssetReferenceTexture3D Constructor Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceTexture3D Constructs a new reference to a Texture3D using its GUID. ```APIDOC ## AssetReferenceTexture3D(string guid) ### Description Constructs a new reference to a Texture3D. ### Method Constructor ### Parameters #### Path Parameters - **guid** (string) - Required - The object guid. ``` -------------------------------- ### AssetReferenceTexture2D Constructor Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceTexture2D Constructs a new reference to a Texture2D using its GUID. ```APIDOC ## AssetReferenceTexture2D(string guid) ### Description Constructs a new reference to a Texture2D asset using its unique identifier (GUID). ### Method Constructor ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```csharp // Example of how to use the constructor (conceptual) string textureGuid = "your_texture_guid_here"; AssetReferenceTexture2D textureReference = new AssetReferenceTexture2D(textureGuid); ``` ### Response #### Success Response (N/A) This is a constructor and does not return a response in the traditional API sense. #### Response Example N/A ``` -------------------------------- ### Addressables Package: Build Player Content with Results (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/changelog/CHANGELOG Demonstrates how to use the `BuildPlayerContent` method from `AddressableAssetSettings` to build player content and retrieve results. This is useful for automating build processes and gathering information about the build. ```csharp AddressableAssetSettings.BuildPlayerContent(out var results); ``` -------------------------------- ### Method Unload Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceProviders.AssetBundleResource Starts an asynchronous operation to unload all resources associated with the AssetBundle. ```APIDOC ## Method Unload ### Description Starts an async operation that unloads all resources associated with the AssetBundle. ### Method `public bool Unload(out AssetBundleUnloadOperation unloadOp)` ### Parameters #### Parameters - **unloadOp** (AssetBundleUnloadOperation) - The async operation. ### Returns #### Returns - **bool** - Returns true if the async operation object is valid. ``` -------------------------------- ### Prefab Spawner: PrefabSpawnerSample (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/SamplesOverview A script that demonstrates instantiating and destroying a prefab using an Addressable AssetReference. Requires the Addressables package and a built Addressable content if using the 'Use Existing Build' Play mode script. Attach this script to a GameObject and assign an Addressable prefab. ```csharp using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; public class PrefabSpawnerSample : MonoBehaviour { public AssetReference prefabReference; private GameObject spawnedInstance; private AsyncOperationHandle loadHandle; void Start() { if (prefabReference != null && prefabReference.ValidateAssetReference()) { Debug.Log("Loading prefab from Addressable: " + prefabReference.AssetGUID); loadHandle = Addressables.InstantiateAsync(prefabReference); loadHandle.Completed += OnPrefabLoaded; } else { Debug.LogError("Prefab reference is not valid or not set."); } } private void OnPrefabLoaded(AsyncOperationHandle handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { spawnedInstance = handle.Result; Debug.Log("Prefab instantiated successfully."); // Optionally parent the spawned instance // spawnedInstance.transform.SetParent(this.transform); } else { Debug.LogError("Failed to load prefab. Status: " + handle.Status); } } void OnDestroy() { // Clean up when the GameObject is destroyed if (spawnedInstance != null) { Addressables.ReleaseInstance(spawnedInstance); Debug.Log("Released spawned prefab instance."); } // If the prefab hasn't loaded yet, release the handle else if (loadHandle.IsValid()) { Addressables.Release(loadHandle); Debug.Log("Released incomplete prefab load handle."); } } // Example of how to destroy the instance if needed later public void DestroyPrefab() { if (spawnedInstance != null) { Addressables.ReleaseInstance(spawnedInstance); spawnedInstance = null; Debug.Log("Prefab manually destroyed."); } } } ``` -------------------------------- ### Get ClassName Property Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.Util.SerializedType Retrieves the name of a type as a string. This property is read-only. ```csharp public string ClassName { get; } ``` -------------------------------- ### Addressables Build Completion Delegate Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.BuildScript Documentation for the global delegate that handles AddressableAssets build results. ```APIDOC ## Field buildCompleted ### Description Global delegate for handling the result of AddressableAssets builds. This will get called for player builds and when entering play mode. ### Namespace UnityEditor.AddressableAssets.Build ### Assembly Unity.Addressables.Editor.dll ### Syntax ```csharp public static Action buildCompleted ``` ### Returns * **Action** - The delegate for handling build completion. ``` -------------------------------- ### Get Duplicated Objects Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.Layout.BuildLayout.AssetDuplicationData Retrieves a list of duplicated objects and the bundles that contain them. ```APIDOC ## GET /websites/unity3d_packages_com_unity_addressables_2_7/buildlayout/duplicatedobjects ### Description Retrieves a list of duplicated objects and the bundles that contain them from the AddressableAssets build layout. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_addressables_2_7/buildlayout/duplicatedobjects ### Parameters #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **DuplicatedObjects** (List) - A list of objects that are duplicated across different bundles, along with information about the bundles they appear in. #### Response Example ```json { "DuplicatedObjects": [ { "objectPath": "Assets/MySharedAsset.asset", "locations": [ { "bundle": "assets/bundles/bundle1.bundle", "guid": "some-guid-1" }, { "bundle": "assets/bundles/bundle2.bundle", "guid": "some-guid-2" } ] } ] } ``` ``` -------------------------------- ### Exposed InitializationOperation (Unity) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/changelog/CHANGELOG The `InitializationOperation` is now exposed as a public API, allowing developers to directly manage and await the Addressables initialization process. ```csharp // Awaiting initialization: // var initOperation = Addressables.InitializeAsync(); // await initOperation; ``` -------------------------------- ### AssetReferenceTexture Constructor Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.AssetReferenceTexture Constructs a new reference to a Texture using its globally unique identifier (GUID). ```APIDOC ## Constructor AssetReferenceTexture(string) ### Description Constructs a new reference to a Texture using its globally unique identifier (GUID). ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp AssetReferenceTexture textureRef = new AssetReferenceTexture("your_texture_guid_here"); ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Launch Addressables Build from Script (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/build-scripting-start-build Initiates the Addressables player content build process. It returns a boolean indicating success based on the AddressablesPlayerBuildResult. If the build fails, an error message is logged. ```csharp static bool buildAddressableContent() { AddressableAssetSettings .BuildPlayerContent(out AddressablesPlayerBuildResult result); bool success = string.IsNullOrEmpty(result.Error); if (!success) { Debug.LogError("Addressables build error encountered: " + result.Error); } return success; } ``` -------------------------------- ### Get Resource Type - C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.ResourceLocators.ContentCatalogDataEntry Retrieves the type of the resource for a given location. This property is read-only and does not take any parameters. ```csharp public Type ResourceType { get; } ``` -------------------------------- ### Get AddressableAssetGroupSchemas - C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Settings.AddressableAssetGroupTemplate Retrieves a list of AddressableAssetGroupSchema objects associated with a template. This property is read-only and returns a List. ```csharp public List SchemaObjects { get; } ``` -------------------------------- ### Provide Method Implementation (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceProviders.Simulation.VirtualAssetBundleProvider This C# code snippet demonstrates the declaration and signature of the 'Provide' method within the Unity Addressables package. It is an override method from the ResourceProviderBase class and takes a ProvideHandle object as input, which contains data for providing the requested object. This method is crucial for the Addressables system to load and deliver assets. ```csharp public override void Provide(ProvideHandle provideHandle) { // Implementation details for providing the object go here. } ``` -------------------------------- ### Method New Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.Util.DefaultAllocationStrategy Creates a new object of a specified type. ```APIDOC ## New(Type, int) ### Description Create a new object of type t. ### Method Not specified (appears to be a static or factory method based on context). ### Endpoint Not applicable (this is a code method, not a REST endpoint). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Example of how to call the New method Type myType = typeof(MyClass); int typeHash = 12345; // Replace with actual hash code object newObject = AllocationStrategy.New(myType, typeHash); ``` ### Response #### Success Response - **object** - The newly created object. #### Response Example ```json { "newObject": "// The created object instance" } ``` ``` -------------------------------- ### Addressables Package - Version 0.5.2-preview Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/changelog/CHANGELOG Release notes for version 0.5.2-preview of the Addressables package, highlighting changes to building, local bundle loading, and new interfaces. ```APIDOC ## Version 0.5.2-preview - 2018-12-14 ### Description Adds version 0.5.2-preview by name. ### IMPORTANT CHANGE TO BUILDING * Automatic asset bundle building has been disabled. This previously occurred when building the player or entering play mode in "packed mode". Now, you must explicitly select "Build->Build Player Content" from the Addressables window or call `AddressableAssetSettings.BuildPlayerContent()`. * This change was made because automatic building did not scale well for large projects. ### Other Changes * Fixed regression loading local bundles. * Added `Addressables.DownloadDependencies()` interface. * Fixes for Nintendo Switch support. * Fixed issues around referencing Addressables during an `Awake()` call. * Code refactoring and naming convention fixes. * Cleaned up missing documentation. * Content update now handles cases where no groups are marked as Static Content. * Fixed errors when browsing for `addressables_content_state.bin` and cancelling. * Moved `addressables_content_state.bin` to be generated into the addressables settings folder. * Changed some exceptions when releasing null bundles to warnings to handle failed download operations. * Separated hash and CRC options to allow independent use in asset bundle loads. * Use CRC in `AssetBundle.LoadFromFileAsync` calls if specified. * Always include `AssetBundleRequestOptions` for asset bundle locations. ``` -------------------------------- ### Property ResourceProviders Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceManager Gets the list of configured IResourceProvider objects. Resource Providers handle load and release operations for IResourceLocation objects. ```APIDOC ## GET /websites/unity3d_packages_com_unity_addressables_2_7/ResourceProviders ### Description Gets the list of configured IResourceProvider objects. Resource Providers handle load and release operations for IResourceLocation objects. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_addressables_2_7/ResourceProviders ### Parameters None ### Request Example None ### Response #### Success Response (200) - **ResourceProviders** (IList) - The resource providers list. #### Response Example { "ResourceProviders": [ // ... list of IResourceProvider objects ] } ``` -------------------------------- ### Create and Use Cache Initialization Settings Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/InitializeAsync Demonstrates how to create a `CacheInitializationSettings` asset and add it to the Addressables initialization objects list to configure Unity's `Cache` settings at runtime. This allows control over cache behavior, such as disabling bundle compression for specific Android versions. ```csharp // In Unity Editor: // 1. Create Cache Initialization Settings asset (Assets > Create > Addressables > Initialization > Cache Initialization Settings). // 2. Select the asset and adjust settings in the Inspector (e.g., disable Compress Bundles). // 3. Open Addressables Settings (Window > Asset Management > Addressables > Settings). // 4. In the Initialization Objects section, click '+' and select the created asset. ``` -------------------------------- ### Get Property Dependencies (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.ResourceLocators.ResourceLocationData Retrieves the collection of dependencies for a given location as an array of strings. This property is read-only and does not require any input parameters. ```csharp public string[] Dependencies { get; } ``` -------------------------------- ### UnknownResourceProviderException Constructors Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.Exceptions Constructors for the UnknownResourceProviderException class. ```APIDOC ## UnknownResourceProviderException Constructors ### UnknownResourceProviderException() Construct a new UnknownResourceProviderException. ### UnknownResourceProviderException(SerializationInfo, StreamingContext) Construct a new UnknownResourceProviderException. ### UnknownResourceProviderException(string) Construct a new UnknownResourceProviderException. ### UnknownResourceProviderException(string, Exception) Construct a new UnknownResourceProviderException. ### UnknownResourceProviderException(IResourceLocation) Construct a new UnknownResourceProviderException. ``` -------------------------------- ### Check for Catalog Updates Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/LoadContentCatalogAsync Use `Addressables.CheckForCatalogUpdates` to get a list of catalogs that have available updates without immediately downloading them. This allows for more granular control over the update process. ```APIDOC ## GET /api/catalogs/updates/check ### Description Checks for available updates for all loaded content catalogs. ### Method GET ### Endpoint `/api/catalogs/updates/check` ### Parameters None ### Request Example (No request body or parameters for this GET request) ### Response #### Success Response (200) - **List** (array) - A list of catalog paths that have available updates. #### Response Example ```json { "message": "Catalog update check complete", "catalogsToUpdate": [ "path_to_catalog1", "path_to_catalog3" ] } ``` ``` -------------------------------- ### BuildLayoutParameters Constructor (Dictionary) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.DataBuilders.BuildLayoutParameters Creates a build layout parameter with a dictionary mapping internal bundle names to file names. ```APIDOC ## BuildLayoutParameters(Dictionary) ### Description Create a build layout parameter with a bundle name remap. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Example usage: var bundleRemap = new Dictionary() { { "internal_bundle_1", "asset_bundle_1.bundle" }, { "internal_bundle_2", "asset_bundle_2.bundle" } }; var layoutParams = new BuildLayoutParameters(bundleRemap); ``` ### Response #### Success Response (200) N/A (Constructor) #### Response Example N/A (Constructor) ``` -------------------------------- ### Get Sub-file Name (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.Layout.BuildLayout.SubFile This C# code snippet demonstrates how to access the 'Name' property, which represents the name of a sub-file within the Addressable Asset build layout. This property returns a string. ```csharp string subFileName = layout.Name; ``` -------------------------------- ### Custom Build and Play mode Scripts: CustomBuildScript (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/SamplesOverview Implements custom build and play mode scripts for the Addressables package. The custom build script creates a build containing only the currently open scene, with an automatically generated initialization scene. It uses predefined build and load paths. Requires Unity's Addressables package. ```csharp using UnityEngine; using UnityEditor; using UnityEditor.AddressableAssets.Build; using UnityEditor.AddressableAssets.Settings; using System.Collections.Generic; public class CustomBuildScript : ICustomBuildLogger { private const string DefaultBuildPath = "[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]"; private const string DefaultRuntimePath = "{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]"; public void Log(string message) { Debug.Log(message); } public void LogWarning(string message) { Debug.LogWarning(message); } public void LogError(string message) { Debug.LogError(message); } // This method would be part of the ICustomBuild script interface public void CreateCustomBuildSetup(AddressableAssetSettings settings) { // Logic to create a build containing only the current scene. // This would involve identifying the active scene, creating a new scene asset that loads it, // and configuring Addressables groups to include these scenes. Debug.Log("Creating custom build setup for the current scene."); // Example: Find or create an initialization scene // Example: Add the current scene to a build group // Example: Set the build and load paths // Placeholder for actual implementation details var buildTarget = EditorUserBuildSettings.activeBuildTarget; var buildPath = DefaultBuildPath.Replace("[BuildTarget]", buildTarget.ToString()); var runtimePath = DefaultRuntimePath.Replace("[BuildTarget]", buildTarget.ToString()); Debug.LogFormat("Build Path: {0}, Runtime Path: {1}", buildPath, runtimePath); } // Other methods required by ICustomBuild or related interfaces would go here. } ``` -------------------------------- ### Get AssetBundleObject Size in C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Build.Layout.BuildLayout.AssetBundleObjectInfo This snippet demonstrates how to access the Size property of an AssetBundleObject in C#. The Size property returns the size in bytes as a ulong. ```csharp namespace UnityEditor.AddressableAssets.Build.Layout { public class AssetBundleObject { public ulong Size { get; } } } ``` -------------------------------- ### ResourceLocationMap Methods (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.AddressableAssets.ResourceLocators Illustrates the key methods of the ResourceLocationMap class. These include adding single or multiple resource locations and locating resources based on a provided key and type. ```csharp public void Add(object key, IList locations); public void Add(object key, IResourceLocation location); public bool Locate(object key, Type type, out IList locations); ``` -------------------------------- ### Get AddressableAssetGroup Schemas (C#) Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEditor.AddressableAssets.Settings.AddressableAssetGroupSchemaSet This C# code snippet demonstrates how to access the list of schemas associated with an AddressableAssetGroup. It utilizes a public property to retrieve the List. ```csharp public List Schemas { get; } ``` -------------------------------- ### Unity C# - Get SetPositionRotation Property Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters Retrieves the value of the SetPositionRotation property, which is a boolean flag indicating whether to set the position and rotation on new instances. This property is read-only. ```csharp public bool SetPositionRotation { get; } ``` -------------------------------- ### UnknownResourceProviderException Properties Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.Exceptions Properties of the UnknownResourceProviderException class. ```APIDOC ## UnknownResourceProviderException Properties ### Location (IResourceLocation) - The location that contains the provider id that was not found. ### Message (string) - Returns a string describing this exception. ``` -------------------------------- ### Get ProviderId in C# Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/api/UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation Retrieves the provider identifier used to load a location in Unity's Addressables system. This property is read-only and returns a string representing the provider's ID. ```csharp string providerId = someLocation.ProviderId; // providerId will contain the ID of the provider used for this location. ``` -------------------------------- ### Unity C# Script to Build Addressables Content and Player Source: https://docs.unity3d.com/Packages/com.unity.addressables@2.7/Packages/com.unity.addressables%402.7/manual/build-scripting-start-build This script defines two menu items under 'Window > Asset Management > Addressables' in the Unity Editor. The first item, 'Build Addressables only', compiles Addressable assets using a specified build script and profile. The second item, 'Build Addressables and Player', first builds the Addressable content and then proceeds to build the Player if the content build is successful. It relies on UnityEditor and UnityEditor.AddressableAssets namespaces. ```csharp #if UNITY_EDITOR using UnityEditor; using UnityEditor.AddressableAssets.Build; using UnityEditor.AddressableAssets.Settings; using System; using UnityEngine; internal class BuildLauncher { public static string build_script = "Assets/AddressableAssetsData/DataBuilders/BuildScriptPackedMode.asset"; public static string settings_asset = "Assets/AddressableAssetsData/AddressableAssetSettings.asset"; public static string profile_name = "Default"; private static AddressableAssetSettings settings; static void getSettingsObject(string settingsAsset) { // This step is optional, you can also use the default settings: //settings = AddressableAssetSettingsDefaultObject.Settings; settings = AssetDatabase.LoadAssetAtPath(settingsAsset) as AddressableAssetSettings; if (settings == null) Debug.LogError($"{settingsAsset} couldn't be found or isn't " + $"a settings object."); } static void setProfile(string profile) { string profileId = settings.profileSettings.GetProfileId(profile); if (String.IsNullOrEmpty(profileId)) Debug.LogWarning($"Couldn't find a profile named, {profile}, " + $"using current profile instead."); else settings.activeProfileId = profileId; } static void setBuilder(IDataBuilder builder) { int index = settings.DataBuilders.IndexOf((ScriptableObject)builder); if (index > 0) settings.ActivePlayerDataBuilderIndex = index; else Debug.LogWarning($"{builder} must be added to the " + $"DataBuilders list before it can be made " + $"active. Using last run builder instead."); } static bool buildAddressableContent() { AddressableAssetSettings .BuildPlayerContent(out AddressablesPlayerBuildResult result); bool success = string.IsNullOrEmpty(result.Error); if (!success) { Debug.LogError("Addressables build error encountered: " + result.Error); } return success; } [MenuItem("Window/Asset Management/Addressables/Build Addressables only")] public static bool BuildAddressables() { getSettingsObject(settings_asset); setProfile(profile_name); IDataBuilder builderScript = AssetDatabase.LoadAssetAtPath(build_script) as IDataBuilder; if (builderScript == null) { Debug.LogError(build_script + " couldn't be found or isn't a build script."); return false; } setBuilder(builderScript); return buildAddressableContent(); } [MenuItem("Window/Asset Management/Addressables/Build Addressables and Player")] public static void BuildAddressablesAndPlayer() { bool contentBuildSucceeded = BuildAddressables(); if (contentBuildSucceeded) { var options = new BuildPlayerOptions(); BuildPlayerOptions playerSettings = BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions(options); BuildPipeline.BuildPlayer(playerSettings); } } } #endif ```