using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; public class LoadModelAB : MonoBehaviour { public GameObject loadtext; public GameObject Model; // Start is called before the first frame update void Start() { StartCoroutine(LoadAB()); } IEnumerator LoadAB() { string filePath = System.IO.Path.Combine(Application.streamingAssetsPath + "/bd", "1"); using (UnityWebRequest req = UnityWebRequestAssetBundle.GetAssetBundle(filePath)) { yield return req.SendWebRequest(); if (req.error == null) { AssetBundle ab = (req.downloadHandler as DownloadHandlerAssetBundle).assetBundle; AssetBundleRequest abr =ab.LoadAssetAsync("1"); yield return abr; Model = GameObject.Instantiate((GameObject)abr.asset); Model.transform.SetParent(this.transform); Model.transform.localEulerAngles = Vector3.zero; Model.transform.localPosition = Vector3.zero; // webglfont = ab.LoadAsset("simkai"); loadtext.SetActive(false); } else { Debug.Log("���س���" + req.responseCode + "," + req.error); loadtext.GetComponent().text=req.error; } } } // Update is called once per frame void Update() { } }