Bundle Protocol

From PowerUI
Revision as of 21:16, 13 January 2017 by 151.229.186.156 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

bundle:// is a slightly unusual protocol (you'll immediately see why) but it's useful none the less. It's used to obtain content from within an AssetBundle:


<!-- An example of an asset called 'assetName' inside a bundle from the web -->
<img src='bundle://https://yoursite.com/bundle.assetbundle#assetName'>

You first specify the full path to the bundle and then the name of the asset inside it that you want as the hash. PowerUI internally handles downloading, loading up and then discovering the asset for you, in one easy to write line. This will work over any protocol that responds with bytes.

The AssetBundle Lookup

PowerUI will not download bundles repeatedly. Instead, it caches bundles by their URL. If multiple files are contained within the same bundle, it will ensure it's loaded just the once. If you would like to access those cached bundles, you can do so using the Bundles class:


AssetBundle bundle = PowerUI.Bundles.Get("https://yoursite.com/bundle.assetbundle");

// Null if not loaded