Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5.  
  6. public class LoadAssetBundle : MonoBehaviour
  7. {
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. StartCoroutine(GetAssetBundle());
  12. }
  13.  
  14. private string url = "http://52.233.172.66/modelos_curso/assetbundledemo";
  15.  
  16. private IEnumerator GetAssetBundle()
  17. {
  18. UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url);
  19.  
  20. yield return www.SendWebRequest();
  21.  
  22. if (www.isNetworkError || www.isHttpError)
  23. {
  24. Debug.LogError(www.error);
  25. }
  26. else {
  27. AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
  28. GameObject prefab = bundle.LoadAsset("PREFAB.prefab") as GameObject;
  29.  
  30. Instantiate(prefab);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement