Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.