Created
March 18, 2016 16:47
-
-
Save tsubaki/490c9576a61edaf7b87f to your computer and use it in GitHub Desktop.
AssetBundle内のスプライトを逐次読込
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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