Alright, I got this working and wrote up a tutorial that I hope will help anyone doing this as well. This is for setting up two projects from scratch. I can’t promise this works for everyone’s specific needs, or that it’s even all necessary for it to work, but hopefully it at least can be modified to suite your needs.
Terms
Primary Project - The project which contains code and from which the application is built from.
Secondary Project - The project containing addressable assets which are built to a remote directory for the Primary Project to reference.
Load Path - The location the addressables from the secondary project will be built to and loaded from.
Setting Up Primary Project
-
Install Addressables package
-
Navigate to Window > Asset Management > Addressables > Groups
-
Click “Create Addressables Settings”
-
Click the “Play Mode Script” drop down and select “Use Existing Build (Windows)”
-
Navigate to Window > Asset Management > Addressables > Profiles
-
Create a new profile or use the default one
-
Right click on the profile and click “Set Active”
-
Change the “Remote” Bundle Location to “Custom”
-
Change the “Remote.LoadPath” to your Load Path
Setting Up Secondary Project
-
Install Addressables package
-
Navigate to Window > Asset Management > Addressables > Groups
-
Click “Create Addressables Settings”
-
Click the “Play Mode Script” drop down and select “Use Existing Build (Windows)”
-
Navigate to Window > Asset Management > Addressables > Profiles
-
Create a new profile or use the default one
-
Right click on the profile and click “Set Active”
-
Change the “Remote” Bundle Location to “Custom”
-
Change the “Remote.LoadPath” and “Remote.BuildPath” to your Load Path
-
Navigate to Window > Asset Management > Addressables > Groups
-
Repeat steps 12 to 14 for every Addressable Group you want to build to the Load Path
-
Select the desired group
-
In the inspector, under “Content Packing & Loading” set the “Build & Load Paths” to “Remote”
-
In the inspector, under “Content Update Restriction” set the “Update Restriction” to “Can Change Post Release”
-
In the inspector, click “System Settings” to open the addressable settings
-
Under Content Update, enable “Build Remote Catalog”
-
Set “Build & Load Paths” to “Remote”
-
Now every addressable in the configured groups will build to the Load Path when you select “Build” > “New Build” > “Default Build Script” in the Addressable Groups window.
Loading Addressables From Primary Project
The primary project must load the content catalog of the secondary project. This is done at runtime. Refer to the following example code which should be executed at the start of the application (or at least before you attempt to load any addressables from the remote location). The “UpdatePath” value should be your Load Path you set as the remote build and load for the projects.
(Following codes uses System.IO, UnityEngine, UnityEngine.AddressableAssets, UnityEngine.AddressableAssets.ResourceLocators, and UnityEngine.ResourceManagement.AsyncOperations)
string contentCatalogPath = "";
var files = Director.GetFiles(updatePath);
foreach (string file in files)
{
string[] splitFileName = file.Split(".");
string fileExtension = splitfileName[splitFileName.Length - 1];
if (fileExtension == "json")
{
string finalPath = file;
finalPath = finalPath.Replace(@"\", "/");
contentCatalogPath = finalPath;
}
}
if (contentCatalogPath == "")
yield return null;
AsyncOperationsHandle<IResourceLocator> handle = Addressables.LoadContentCatalogAsync(contentCatalogPath, true);
Once this code is executed in runtime, addressables from the secondary project can be loaded like normal during runtime such as with “LoadAddressableAsync”.
Good luck!
P.S. I’ve seen an error where it fails to load the unity default shader bundle. This is because the bundle name is hashed and so the name is different between the two projects which the prefabs from the secondary project looking for the wrong bundle. Right now, I get around this by copying the bundle that is generated on a project build in the secondary project to the build of the first project (resulting in two shader bundles). If you see this error, it will show the file path to these files.