Skip to content

Instantly share code, notes, and snippets.

@ssabii
Created October 30, 2019 15:07
Show Gist options
  • Save ssabii/4deea2ab5abb252d09c68971dde1b522 to your computer and use it in GitHub Desktop.
Save ssabii/4deea2ab5abb252d09c68971dde1b522 to your computer and use it in GitHub Desktop.
에셋번들에 있는 모든 에셋을 로드하는 코드
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class LoadAllAssetBundles : MonoBehaviour {
// Use this for initialization
void Start () {
StartCoroutine(LoadAssetBundle());
}
IEnumerator LoadAssetBundle()
{
string uri = "file:///" + Application.dataPath + "/AssetBundles/bundle";
UnityWebRequest request = UnityWebRequest.GetAssetBundle(uri);
yield return request.SendWebRequest();
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
GameObject[] assets = bundle.LoadAllAssets<GameObject>();
foreach(GameObject asset in assets)
{
Instantiate(asset);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment