top of page
Search
theresipetani

Unity Asset Bundle 3 Oct 2018



Note that all methods used to load resources from asset catalogs also have an optional bundle attribute you can provide in case you want to load assets from a bundle that's not your app's main bundle, like so:




Unity Asset Bundle 3 Oct 2018



With the upcoming release of ChibiStudio 2.0, we're moving the item packs to bundles and asset catalogs. A very important aspect of ChibiStudio since day one is that we want it to work without an internet connection and we want users to be able to use purchased item packs right away, without having to wait for a download to finish, this means we need to ship every single item pack with the app itself.


1 - A bundle for each pack, the bundle contains an asset catalog which has an asset for each item's vector data and another asset for each item's preview image. The preview image is compressed using the new HEIF compression available on iOS 12, which makes the files smaller. We ended up not using the compression because of performance constraints.


This is only possible through the use of bundles. You can't have multiple asset catalogs in a single bundle, if you create multiple catalogs in a single target in Xcode, they all get compiled to a single Assets.car file at the end. Separating the packs into their own bundles also makes it possible for us to add new features to packs in the future, such as metadata in the Info.plist file or even executable code.


Since packs are created in the editor, it was necessary to add the asset catalog and bundle generator functionality to the app itself, the finished bundles are then imported into Xcode and added to the app's resources in the build phases.


To generate bundles in the Editor, I created a template bundle which is embedded in the editor, after compiling the asset catalog for a pack, the editor copies this bundle template into the destination directory, moves the asset catalog into the bundle and creates its Info.plist file.


The result is a bundle with an Info.plist file and an Assets.car file, the bundle is located with the technique mentioned before, preview image assets are loaded using UIImage and vector data assets are loaded using NSDataAsset.


I didn't want to end this article without providing some sample code for you to play with, so I made a very simple app that uses bundles for theming. The app has two bundles: Light.bundle and Dark.bundle. Each bundle has its own asset catalog with color definitions and a config asset containing configuration for that theme.


This is a very simple example, with the same technique you could change more about your app depending on the theme, such as metrics (spacing, sizes, etc), images, or anything else that can be stored in an asset catalog or bundle.


In the sample app, I created the theme bundles using Xcode, but you could also create a simple Mac app as a theme editor for your iOS app and generate the bundles from that app, this app could then be given to your design team, giving them full flexibility when creating themes, without the need to install Xcode, deal with JSON or property lists and taking full advantage of asset catalogs.


I am working in unity 2018 Asset Bundle. In my project i have to pack the entire sceneinside of an AssetBundle and when i needed, the game will download the AssetBundle from the internet and then it should unpack it.


The whole concept of assetbundle is to load stuff, on-demand. Loading the whole scene seems a bad pattern. Also, the whole script layer is lost, when using asset bundles. If you need to load a big environment or something bigger, just put it in a prefab.


A simplified version of the script that I use for loading asset bundles is as follows. (This has been hugely simplified for brievity, including stripping out all object caching and error handling, etc)


Today marks the beginning of KotlinConf 2018 - the largest in-person gathering of the Kotlin community annually. 2018 has been a big year for Kotlin, as the language continues to gain adoption and earn the love of developers. In fact, 27% of the top 1000 Android apps on Google Play already use Kotlin. More importantly, Android developers are loving the language with over 97% satisfaction in our most recent survey. It's no surprise that Kotlin was voted as the #2 most-loved language in the 2018 StackOverflow survey.


That makes sense, but this has never happened to me before despite having almost every scene in my project downloaded as an asset bundle (around 15 scenes). Only since U4 have I seen this. I have been using asset bundles in this same project for over 2 years!?


Every time I change ANY code, I now have to wait 20 minutes to rebuild all my asset bundles to be able to test the game. This really can't be right. It will take me an eternity to finish this way. I noticed that even when I make a small change in one file ALL my asset bundles get the mismatch error even though I can't see ANY references to the main build within the bundles themselves.What counts as a reference (A script call ie GetComponent or something else?)


The annual Unity Mega Bundle is on right now, a collection of Unity assets bundle together with savings up to 95% off. The Bundle is organized into tiers, where higher dollar value tiers include all the tiers below it. The Mega Bundle tiers include: 2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page