Unity3d AssetBundle 学习 打包相关(学的时候用的unity2017)

 

打包之前需要将资源的名字取好,名字中'/'符号会在打包一手生成在相应的文件夹中,比如上图所示的名字,打包之后会在“指定生产的AssetBundle路径下/aaa/bb.u3d”生成这样的文件。

 

其实打包bundle包用官网的插件就好了(在手册里的"Unity Assetbundle Browser tool"可以看到)

 1 using UnityEditor;
 2 using System.IO;
 3 using UnityEngine;
 4 public class CreateAssetBundles
 5 {
 6     [MenuItem("Assets/Build AssetBundles")]
 7     static void BuildAllAssetBundles()
 8     {
 9         string assetBundlesDirectory = Application.streamingAssetsPath + "/AssetBundles";
10         if (!Directory.Exists(assetBundlesDirectory))
11         {
12             Directory.CreateDirectory(assetBundlesDirectory);
13         }
14         //第二个参数和第三个参数可根据情况做相应调整
15         BuildPipeline.BuildAssetBundles(assetBundlesDirectory, BuildAssetBundleOptions.None, BuildTarget.Android);
16     }
17 }

 

posted on 2019-05-08 23:38  炼金师  阅读(271)  评论(0)    收藏  举报

导航