In the manual of AssetBundle usage, https://docs.unity3d.com/Manual/AssetBundles-Native.html
I can see that when use LoadAsset
loaded an GameObject, why we need to do the extra step Instantiate
it ? this will create another copy of the prefab, I'm confuse why we do not use the loaded prefab
GameObject directly?
public class LoadFromFileExample extends MonoBehaviour {
function Start() {
var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "myassetBundle"));
if (myLoadedAssetBundle == null) {
Debug.Log("Failed to load AssetBundle!");
return;
}
var prefab = myLoadedAssetBundle.LoadAsset.<GameObject>("MyObject");
Instantiate(prefab); // why do not use prefab directly ?
}
}