- Home /
Creating/Using a Google Play OBB with Unity 3.5
Hello! This question is already half-answered as I ask it, so I hope that this will become a resource for others to use after we're all done here today! I'm needing to package an OBB with my APK file (it's still hovering at 80MB even after intense asset crunching). I'm starting to feel comfortable with the ideas of packaging and using an OBB with Unity 3 (the version we're using), and having been drawing heavily upon these forums:
http://forum.unity3d.com/threads/135224-More-Google-OBB-drama
http://forum.unity3d.com/threads/150095-Split-APK-amp-Google-Play-OBB-Downloader-Question
http://forum.unity3d.com/threads/150806-How-to-create-an-OBB-data
At this point, I:
Have the Google Play OBB Downloader from the Asset Store and have merged the Android Manifest file with my pre-existing one.
Know that I need to create OBB from a series of Asset Bundles.
Know that I need a Loader Scene which calls GooglePlayDownloader.FetchOBB() and then loads my first scene
So my questions are: How should I organize the asset bundles? Is there a way for me to simply package everything so my current structure of accessing levels through the Resources folder doesn't need to be changed? Can I just package textures and sounds into an asset bundle and will it re-associate with the prefabs correctly at runtime after unpacking?
How do I exclude the assets that I've packaged into an Asset Bundle from the initial APK file?
How does updating the application work? Do we re-upload a new APK and OBB on each update?
Thanks a million guys. I hope that these questions get answered and that the result is useful for more than just me!
Answer by Arkasis · Mar 26, 2013 at 11:04 AM
Hi,
if you are using unity 4 and the 'Split apk' option, you don't have to take care of your asset bundles.
Just create your project like a normal project and then, create a loader scene using the GooglePlay Obb downloader package. (Don't forget to complete the manifest).
The split apk option will cut your project in two pieces. One main .apk with your first scene downloading the second .obb part (if it is not) and using it like if it was a part of your .apk.
The .obb and .apk are totally linked. So if you have to do an update, build your application using 'Split apk' again and upload the two files again. (You could create your own update manager if you just add content and don't modify current content using asset bundles).
If you are using Unity3, you have to regroup all assets used in your game and make an assets bundle with. Then zip it in a .obb ($> zip -0 main.obb assetbundles). Load your .obb file with GooglePlay Obb downloader package example and then use WWW.LoadFromCacheOrDownload(jar:file://" + obbPath + "!/" + originalAssetBundleName); to load your assetsBundle from your obb file.
To organize your assetsBundle, only exclude all objects used in your first scene (Loader_scene) from your assetsBundle. When you build your application, only select your downloader scene and Unity will only include assets used on this scene to your .apk. All the other scenes could be loaded from an assetsBundle in runtime.
I hope I help you.
Good luck !