WuhuIslandTesting/Library/PackageCache/com.unity.addressables@1.21.12/Documentation~/editor/profiles/AddressableAssetsProfiles.md
2025-01-07 02:06:59 +01:00

8.5 KiB
Raw Permalink Blame History

uid
addressables-profiles

Profiles

A profile contains a set of variables used by the Addressables build scripts. These variables define information such as where to save build artifacts and where to load data at runtime. You can add custom profile variables to use in your own build scripts.

Open the Profiles window (menu: Window > Asset Management > Addressables > Profiles) to edit profile values and create new profiles.


The Addressables Profiles window showing the default profile.

You can set up different profiles for the different phases or tasks in your development process. For example, you could create one profile to use while developing your project, one to use for testing, and one to use for final publishing or release. Setting up the profiles in advance and swapping between them is much less error prone than editing the values individually when you move to a different phase or perform a different task.

Right-click a profile name to set it as the active profile, rename the profile, or delete it.

Addressables defines five profile variables by default:

  • Local: defines two path variables for local content:
    • Local.BuildPath: where to build the files containing assets you want to install locally with your application. By default, this path is inside your Project Library folder.
    • Local.LoadPath: where to load assets installed locally with your application. By default, this path is in the StreamingAssets folder. Addressables automatically includes local content built to the default location in StreamingAssets when you build a Player (but not from other locations).
  • Remote: defines two path variables for remote content:
    • Remote.BuildPath: where to build the files containing assets you plan to distribute remotely.
    • Remote.LoadPath: the URL from which to download remote content and catalogs.
  • BuildTarget: the name of the build target, such as Android or StandaloneWindows64

You can choose the following pre-defined Bundle Locations for the Local and Remote path variables:

  • Built-In: the path definitions for local content. The build system automatically includes content built with this setting in your Player builds. You should not change these path values.
  • Editor Hosted: the path definitions to use with the Editor [Hosting service]. Depending on how you set up the hosting service, you might need to edit the load path to match the service URL.
  • Cloud Content Delivery: the path definitions for the Unity Cloud Content Delivery (CCD) service. Requires creating a Unity Project ID in the Services section of your Project settings (or linking to an existing ID). You must also install the CCD Management SDK package. See Addressable Asset system with Cloud Content Delivery for information about setting up and using the Cloud Content Delivey Bundle Location option.
  • Custom: Allows you to edit the values used for the build and load paths. See Profile variable syntax for information about setting a variable value using placeholders that Addressables evaluates at build-time and runtime.

Warning

In most cases, you should not change the local build or load paths from their default values. If you do, you must manually copy the local build artifacts from your custom build location to the project's StreamingAssets folder before making a Player build. Altering these paths also precludes building your Addressables as part of the Player build.

See Builds for more information about how Addressables uses profiles during content builds.

Tip

Using multiple profiles is most helpful when you distribute content for your application remotely. If you distribute all content as part of your application install, then the single, default profile might be the only profile you need.

Setting the active profile

The active profile determines the set of variables used when you run a build script.

To set the active profile, either:

  1. Open the Groups window (menu: Window > Asset Management > Addressables > Groups).
  2. Click the Profile menu in the toolbar.
  3. Choose the profile to make active.

Or:

  1. Open the Profiles window (menu: Window > Asset Management > Addressables > Profiles).
  2. Right- or cmd-click on a profile to open the context menu.
  3. Choose Set Active.

Note

Build scripts include the Play Mode Scripts that Addressables invokes when you enter Play mode in the Editor. Some Play Mode scripts use variables from the active profile to locate content. See Play Mode Scripts for more information.

Adding a new profile

To create a new profile, select Create > Profile. A new profile row appears in the table.

Every profile must define a value for every variable. When you create a new profile, Addressables copies all values from the currently selected profile.

Profile variables

See [Profile Variables] for more information on how to use profile variables.

Specifying packing and loading paths

Once you set up the necessary variables in your profile, you can select the build and load paths for an asset group based on those specified variables.

To set your build and load paths:

  1. Select an Addressable Assets group from the Project window.
  2. In the groups Inspector, under Content Packing & Loading > Build and Load Paths, select the desired path pair. If you choose the <custom> option, you can specify the build and load paths separately.

Notice that you do not enter the path directly, but rather select a variable representing the path defined in the Profiles window earlier. The Path Preview shows the current path, based on the active Profile. To edit a path directly in the Group settings Inspector, set Build & Load Paths to <custom> and also set the individual Build or Load Path to <custom>. The edited path applies to that group only.

Profile examples

Consider the following example, demonstrating the local development phase of your content.


Content with local and remote bundles stored locally for development.

While in development, you would have both your local and remote bundles using local paths, as seen below.


Paths set for local development.

In this instance, you can see that the local and remote paths are in fact local, which makes it unnecessary to set up a remote server just for local development.

Once the content is ready for production, you would move the remote bundles to a server, as the diagram below shows.


Content with the remote bundles moved to a server for production.

In this case, using profiles, you could change the remote load path for "Production" to that server. Without having to change your asset groups, you can change all of your remote bundles to actually become remote.


Paths set for hosting remote content

Important

  • The Addressables system only copies data from Addressables.BuildPath to the StreamingAssets folder during a Player build -- it does not handle arbitrary paths specified through the LocalBuildPath or LocalLoadPath variables. If you build data to a different location or load data from a different location than the default, you must copy the data manually.
  • Similarly, you must manually upload remote AssetBundles and associated catalog and hash files to your server so that they can be accessed at the URL defined by RemoteLoadPath.