Skip to content

Instantly share code, notes, and snippets.

@ssabii
Created October 30, 2019 10:28
Show Gist options
  • Save ssabii/c6ca216896af2028ed5a7e50c016ae58 to your computer and use it in GitHub Desktop.
Save ssabii/c6ca216896af2028ed5a7e50c016ae58 to your computer and use it in GitHub Desktop.
바이트 배열을 읽어서 애셋번들을 로드하는 코드
using System.Collections;
using System.IO;
using UnityEngine;
public class LoadAssetBundlesFromMemory : MonoBehaviour {
// Use this for initialization
void Start()
{
string path = "Assets/AssetBundles/bundle";
StartCoroutine(LoadFromMemoryAsync(path));
}
// Update is called once per frame
void Update()
{
}
IEnumerator LoadFromMemoryAsync(string path)
{
AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(path));
yield return request;
AssetBundle bundle = request.assetBundle;
var prefab = bundle.LoadAsset<GameObject>("Stone");
Instantiate(prefab);
prefab = bundle.LoadAsset<GameObject>("Brick");
Instantiate(prefab);
}
}
Copy link

ghost commented Oct 30, 2019

prefab = bundle.LoadAsset

@ssabii
Copy link
Author

ssabii commented Oct 30, 2019

@kapuswetha Thank you for your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment