lbry-unity/LBRY 3D Viewer/Assets/Scenes/LBRY/RenderModelScript.cs

36 lines
837 B
C#
Raw Permalink Normal View History

2019-01-06 23:48:29 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class RenderModelScript : MonoBehaviour {
void Start() {
StartCoroutine(GetAssetBundle());
}
IEnumerator GetAssetBundle() {
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle("./lbry.assetbundle");
yield return www.SendWebRequest();
if(www.isNetworkError || www.isHttpError) {
Debug.Log(www.error);
} else {
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
var assetNames = bundle.GetAllAssetNames();
Debug.Log(assetNames[0]);
Instantiate(bundle.LoadAsset(assetNames[0]));
bundle.Unload(false);
}
}
// Update is called once per frame
void Update() {
}
}