Skip to content

Instantly share code, notes, and snippets.

@kou-yeung
Last active May 15, 2020 09:26
Show Gist options
  • Save kou-yeung/cee45275121f4b515510de486ea1c67a to your computer and use it in GitHub Desktop.
Save kou-yeung/cee45275121f4b515510de486ea1c67a to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AddressableAssetsTool;
public class Sample : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// set the BASE URL
AddressableAssets.Init("{{BASE_URL}}");
// Get Preload size need to download
AddressableAssets.GetSizeAsync("Preload").Completed += (res) =>
{
var size = res.Result;
if (size > 0)
{
// need to download update
var handle = AddressableAssets.DownloadDependenciesAsync("Preload");
handle.Completed += (preload) =>
{
// download completed. change to next scene!!
};
} else
{
// no need download. change to next scene!!
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment