Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created March 18, 2016 16:47
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/490c9576a61edaf7b87f to your computer and use it in GitHub Desktop.
Save tsubaki/490c9576a61edaf7b87f to your computer and use it in GitHub Desktop.
AssetBundle内のスプライトを逐次読込
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LoadAssetbundle : MonoBehaviour
{
IEnumerator Start ()
{
var image = GetComponent<Image> ();
var fileNames = new string[] { "01制服哀", "01制服喜", "01制服怒", "01制服楽", "01私服哀", "01私服喜", "01私服怒", "01私服楽" };
var assetbundleNames = new string[] { "/chara1", "/chara2", "/chara3" };
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 );
foreach (var file in fileNames) {
var asset = assetbundle.LoadAsset<Sprite> (file);
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