lbry-unity/LBRY 3D Viewer/Assets/Scenes/LBRY/RenderModelScript.cs
2019-01-06 16:48:29 -06:00

35 lines
837 B
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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() {
}
}