Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created November 13, 2015 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tsubaki/847b73767df7cacbd255 to your computer and use it in GitHub Desktop.
Save tsubaki/847b73767df7cacbd255 to your computer and use it in GitHub Desktop.
Load Multiple Sprite
using UnityEngine;
using System.Collections;
using System;
public class LoadAB : MonoBehaviour {
IEnumerator Start ()
{
enabled = false;
WWW www = new WWW ("file://" + Application.streamingAssetsPath + "/player");
yield return www;
var sprites = www.assetBundle.LoadAssetWithSubAssets<Sprite> ("RobotBoyJumpSprite");
var sprite = Array.Find (sprites, item => item.name == "RobotBoyJump00");
www.assetBundle.Unload (false);
var spriteRenderer = gameObject.AddComponent<SpriteRenderer> ();
spriteRenderer.sprite = sprite;
enabled = true;
Resources.UnloadUnusedAssets ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment