当前位置:网站首页>Unity load AB package
Unity load AB package
2022-07-06 20:13:00 【LiPing122335】
Load asynchronously
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
public class LaodAB : MonoBehaviour {
// Use this for initialization
void Start () {
StartCoroutine("LoadWed");
//LoadFile();
}
void LoadFile()
{// Local
AssetBundle ab = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "my2"));
GameObject go = ab.LoadAsset<GameObject>("Cube");
GameObject g = Instantiate(go);
//g.transform.SetParent(GameObject.Find("Canvas").transform, false);
}
IEnumerator LoadWed()
{
string uri = "file:///" + Application.dataPath + "/StreamingAssets/my2";
UnityWebRequest request = UnityWebRequest.GetAssetBundle(uri);
yield return request.Send();
AssetBundle ab = DownloadHandlerAssetBundle.GetContent(request);
//AssetBundle ab = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "my2"));
GameObject go = ab.LoadAsset<GameObject>("Cube");
GameObject g = Instantiate(go);
}
void Update () {
}
}
边栏推荐
- 02 基础入门-数据包拓展
- Is it difficult for small and micro enterprises to make accounts? Smart accounting gadget quick to use
- 精彩编码 【进制转换】
- Recursive implementation of department tree
- Example of applying fonts to flutter
- 5. 无线体内纳米网:十大“可行吗?”问题
- 5. Wireless in vivo nano network: top ten "feasible?" problem
- After solving 2961 user feedback, I made such a change
- Introduction of Xia Zhigang
- logstash高速入口
猜你喜欢
随机推荐
Groovy basic syntax collation
POJ 3207 Ikki&#39; s Story IV – Panda&#39; s Trick (2-SAT)
js实现力扣71题简化路径
腾讯T3手把手教你,真的太香了
Vscode debug run fluent message: there is no extension for debugging yaml. Should we find yaml extensions in the market?
beegfs高可用模式探讨
Groovy基础语法整理
【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
永磁同步电机转子位置估算专题 —— 基波模型类位置估算概要
【云原生与5G】微服务加持5G核心网
腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
腾讯T3大牛手把手教你,大厂内部资料
Introduction of Xia Zhigang
JVM_ Common [interview questions]
Selenium advanced operations
Period compression filter
Problems encountered in using RT thread component fish
RT thread I2C tutorial
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
Leetcode brush first_ Maximum Subarray