Book Image

Unity 5 for Android Essentials

By : Valera Cogut
Book Image

Unity 5 for Android Essentials

By: Valera Cogut

Overview of this book

Table of Contents (14 chapters)
Unity 5 for Android Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Downloading new code and data in real time for Android devices


In the event of retrieving assets from your bundles, you can use three separate functions:

  • AssetBundle.Load: This will load one object only by the given name; also it will block the main thread.

  • AssetBundle.LoadAsync: This will load one object only by a given name; it will not block the main thread. Use this method for huge assets.

  • AssetBundle.LoadAll: This will load every object from your AssetBundle.

Use the AssetBundle.Unload method in the event of unloading assets. Let's look at a simple usage example of the asynchronous method as shown in the following code without any exception handling and any checks (just as skeleton):

using UnityEngine;
using System.Collections;

public class GetAssetBundleAsync : MonoBehaviour {
  public string assetBundleUrl = "http://yourweb.com/yourBundle.unity3d";
  public int assetBundleVersion = 1;

  IEnumerator Start() {
    WWW www = WWW.LoadFromCacheOrDownload(
      assetBundleUrl, assetBundleVersion...