Created
October 30, 2019 10:28
-
-
Save ssabii/c6ca216896af2028ed5a7e50c016ae58 to your computer and use it in GitHub Desktop.
바이트 배열을 읽어서 애셋번들을 로드하는 코드
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 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); | |
} | |
} |
@kapuswetha Thank you for your response.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
prefab = bundle.LoadAsset