AssetBundles can become dependant on other AssetBundles if one or more of the
UnityEngine.Objects contains a reference to a
UnityEngine.Object located in another bundle. A dependency does not occur if the UnityEngine.Object contains a reference to a
UnityEngine.Object that is not contained in any AssetBundle. In this case, a copy of the object that the bundle would be dependant on is copied into the bundle when you build the AssetBundles. If multiple objects in multiple bundles contain a reference to the same object that isn’t assigned to a bundle, every bundle that would have a dependency on that object will make its own copy of the object and package it into the built AssetBundle.
Should an AssetBundle contain a dependency, it is important that the bundles that contain those dependencies are loaded before the object you’re attempting to instantiate is loaded. Unity will not attempt to automatically load dependencies.
Considerando el siguiente ejemplo, un Material en unas referencias Bundle 1 a una Textura en una Bundle 2:
In this example, before loading the Material from Bundle 1, you would need to load Bundle 2 into memory. It does not matter which order you load Bundle 1 and Bundle 2, the important takeaway is that Bundle 2 is loaded before loading the Material from Bundle 1. In the next section, we’ll discuss how you can use the
AssetBundleManifest objects we touched on in the previous section to determine, and load, dependencies at runtime.