Created
November 13, 2015 10:53
-
-
Save tsubaki/847b73767df7cacbd255 to your computer and use it in GitHub Desktop.
Load Multiple Sprite
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 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