Skip to content

Instantly share code, notes, and snippets.

@ssabii
Created October 30, 2019 14:14
Show Gist options
  • Save ssabii/2dd2c7786752cf7a523104b4b26c152e to your computer and use it in GitHub Desktop.
Save ssabii/2dd2c7786752cf7a523104b4b26c152e to your computer and use it in GitHub Desktop.
UnityWebRequest로 에셋번들을 로드하는 코드
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class LoadAssetBundlesFromUnityWebRequest : 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);
var prefab = bundle.LoadAsset<GameObject>("Stone");
Instantiate(prefab);
prefab = bundle.LoadAsset<GameObject>("Brick");
Instantiate(prefab);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment