- Home /
Unity Cloud Build with Addressables for WebGL
I have a WebGL project in which I have recently implemented a very simple (ha!) use case of Addressables using the following code:
public void LoadRandomLlamas()
{
int llamaToLoad = Random.Range(0, 2);
Vector3 randomLocation = new Vector3(Random.Range(minX, maxX), 15.05f, Random.Range(minZ, maxZ));
StartCoroutine(AddressablesLoader.InstantiateAddressable(llamas[llamaToLoad], randomLocation));
}
Where AddressablesLoader.InstantiateAddressable() is:
// Load a single addressable asset.
public static IEnumerator InstantiateAddressable(string addressableAssetAddress, Vector3 location)
{
AsyncOperationHandle<GameObject> loadingAsset = Addressables.InstantiateAsync(addressableAssetAddress);
yield return loadingAsset;
GameObject loadedObject = loadingAsset.Result;
loadedObject.transform.position = location;
}
This works perfectly locally; however, when I do a Unity Cloud build I get the following error messages:
Exception encountered in operation InitializationOperation, status=Failed, result= : Addressables - Unable to load runtime data at location UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[[UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData, Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].
Exception encountered in operation CompletedOperation, status=Failed, result= : Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Assets/Suriyun/Cute Pet/Prefab/Alpaca.prefab, Type=UnityEngine.GameObject
Exception encountered in operation ChainOperation - InitializationOperation, status=Failed, result= : ChainOperation of Type: UnityEngine.GameObject failed because dependent operation failed Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Assets/Suriyun/Cute Pet/Prefab/Alpaca.prefab, Type=UnityEngine.GameObject
And finally, because of the aforementioned:
NullReferenceException: Object reference not set to an instance of an object.
To preempt any easy solutions, yes, I have already checked the box under Config in the Unity Dashboard to use Addressables in Unity Cloud Build.
I also attempted to check the box for Content Update Build and set that up on the Unity side, but that did nothing.
I've been spinning my wheels on this for some time, and would appreciate any help!