Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class LoadAssetBundle : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine(GetAssetBundle());
- }
- private string url = "http://52.233.172.66/modelos_curso/assetbundledemo";
- private IEnumerator GetAssetBundle()
- {
- UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url);
- yield return www.SendWebRequest();
- if (www.isNetworkError || www.isHttpError)
- {
- Debug.LogError(www.error);
- }
- else {
- AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
- GameObject prefab = bundle.LoadAsset("PREFAB.prefab") as GameObject;
- Instantiate(prefab);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement