0
votes

New to Unity so pardon any mishaps.

Till now I have:

1- created an asset bundle

2- uploaded it to server

3- downloaded the asset bundle

4- extracted objects from the asset bundle and used (instantiated) them "in game" via script.

Now the issue is, after downloading it, could I store the asset bundle in some directory, or for instance, instead of instantiating the game objects, could I save them in some directory as .prefab files. Or am I limited to extract the objects at run-time and "ONLY ABLE INSTANTIATE" them?

Edit: Other answers on this forum do tell how to store the asset bundle as a *.unity3d file. What I want different is not to store the bundle as a single file, but extract its constituents in some directory.

Thanks

1
You can save assetbundle you downloaded. Not as ".prefab" but as ".unity3d"Programmer
yes but the problem remains. Whenever I need to access something from the assetbundle, I need to "load" it again (first I did from web, now from file). What I wanted was if I could download it once, extract all its constituents to some directory and use them without having to load the entire asset bundle again.Ammar Aslam
You can't. I've removed the duplicate since that's not what you are asking. See my answer for another option you haveProgrammer

1 Answers

3
votes

could I save them in some directory as .prefab files.

No. You can't do this because you can't create and load prefab during run-time outside the Editor. The only prefabs you can load are the one created in the Editor and bundled with the game.

One option you have is to download and save the assetbundle as with the ."unity3d" extension as described in this answer.

Another option is to individually convert each file and save them. For example, if the assetbundle contains Textures, convert it to png or jpeg with EncodeToPNG then save it. You can then load it with LoadImage. This can be done to audio, video files too by saving them in ".mp3" and ".mp4" format. The videos and audios can be loaded with the UnityWebRequest API after saving them. This won't work with prefab.