本文共 1092 字,大约阅读时间需要 3 分钟。
01.生成AB包 02.使用资源文件//加载AB包 AssetBundle asset= AssetBundle.LoadFromFile(Application.streamingAssetsPath+ "/model"); //加载资源 Instantiate(asset.LoadAsset("Cube"));
public Image image; IEnumerator Load(string abName,string iconName) { AssetBundleCreateRequest request=AssetBundle.LoadFromFileAsync(Application.streamingAssetsPath + "/" + abName); yield return request; AssetBundleRequest sprite=request.assetBundle.LoadAssetAsync(iconName); yield return sprite; image.sprite = sprite.asset as Sprite; }
03.资源依赖
AssetBundle asset= AssetBundle.LoadFromFile(Application.streamingAssetsPath+ "/model"); AssetBundle assetMain=AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/PC"); AssetBundleManifest abMainfest=assetMain.LoadAsset("AssetBundleManifest"); string[] str=abMainfest.GetAllDependencies("model"); for (int i = 0; i < str.Length; i++) { AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/" + str[i]); }
04.AB管理器
转载地址:http://lfrxo.baihongyu.com/