Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active March 18, 2016 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/6882a26b048ea95b082d to your computer and use it in GitHub Desktop.
Save tsubaki/6882a26b048ea95b082d to your computer and use it in GitHub Desktop.
ファイル一覧を一括ロード
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LoadAssetbundle : MonoBehaviour
{
IEnumerator Start ()
{
var image = GetComponent<Image> ();
var assetbundleNames = new string[] { "/character1", "/character2", "/character3" };
// クリック待ち
yield return new WaitWhile (() => Input.GetMouseButtonDown (0) == false);
float time = Time.realtimeSinceStartup;
// AssetBundleに格納されているスプライトを全部取り出す
foreach (var assetbundlename in assetbundleNames) {
var assetbundle = AssetBundle.LoadFromFile (Application.streamingAssetsPath + assetbundlename);
var assets = assetbundle.LoadAllAssets<Sprite> ();
foreach(var asset in assets){
image.sprite = asset;
}
assetbundle.Unload (false);
}
Debug.Log (Time.realtimeSinceStartup - time);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment