123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using TriLibCore;
- using UnityEngine;
- using UnityEngine.Networking;
- public class Loadmp4 : MonoBehaviour
- {
- public string strs;
- // Start is called before the first frame update
- void Awake()
- {
- StartCoroutine(LoadAB());
- }
- IEnumerator LoadAB()
- {
- string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "ui/"+strs);
- //UnityWebRequest request = UnityWebRequest.Get(filePath);
- Debug.Log("LoadAB====>"+ filePath);
- using (UnityWebRequest req = UnityWebRequestAssetBundle.GetAssetBundle(filePath))
- {
- yield return req.SendWebRequest();
- if (req.error == null)
- {
- Debug.Log("LoadAB====>start");
- AssetBundle ab = (req.downloadHandler as DownloadHandlerAssetBundle).assetBundle;
- GameObject go = GameObject.Instantiate( ab.LoadAsset<GameObject>(strs),this.transform);
- go.SetActive(true);
- Debug.Log("LoadAB====>end");
- // UI.SetActive(true);
- }
- else
- {
- Debug.Log(filePath);
- }
- }
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
|