Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created July 24, 2017 12:42
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/e8f64dc3c79bf44ab9227b81681aa724 to your computer and use it in GitHub Desktop.
Save tsubaki/e8f64dc3c79bf44ab9227b81681aa724 to your computer and use it in GitHub Desktop.
StreamからAssetBundleを取得する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class LoadAssetbundle : MonoBehaviour {
void Start () {
Sprite sprite;
using (FileStream reader = new FileStream (Application.streamingAssetsPath + "/data", FileMode.Open)) {
var ab = AssetBundle.LoadFromStream (reader);
sprite = ab.LoadAsset<Sprite> ("CratePinkGridSprite");
ab.Unload (false);
}
GetComponent<SpriteRenderer> ().sprite = sprite;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment