示例#1
0
        /// <summary>
        /// 自动构建ab
        /// </summary>
        /// <param name="assets"></param>
        /// <param name="outPath"></param>
        /// <param name="abName"></param>
        /// <param name="bbo"></param>
        static public void BuildABs(string[] assets, string outPath, string abName, BuildAssetBundleOptions bbo)
        {
            AssetBundleBuild[] bab = new AssetBundleBuild[1];
            bab[0].assetBundleName = abName; //打包的资源包名称 随便命名
            bab[0].assetNames      = assets;
            if (string.IsNullOrEmpty(outPath))
            {
                outPath = EditorUtils.GetOutPutPath();
            }

            string tmpPath = EditorUtils.GetProjectTempPath();

            EditorUtils.CheckDirectory(tmpPath);
            string tmpFileName = Path.Combine(tmpPath, abName);

            BuildPipeline.BuildAssetBundles(tmpPath, bab, bbo, target);

            string   targetFileName = Path.Combine(outPath, abName);
            FileInfo tInfo          = new FileInfo(targetFileName);

            if (tInfo.Exists)
            {
                tInfo.Delete();
            }
            FileInfo fino = new FileInfo(tmpFileName);

            fino.CopyTo(targetFileName);
        }
示例#2
0
        /// <summary>
        /// 自动构建abs
        /// </summary>
        /// <param name="assets"></param>
        /// <param name="outPath"></param>
        /// <param name="abName"></param>
        /// <param name="bbo"></param>
        static public void BuildABs(AssetBundleBuild[] bab, string outPath, BuildAssetBundleOptions bbo)
        {
            if (string.IsNullOrEmpty(outPath))
            {
                outPath = EditorUtils.GetOutPutPath();
            }

            string tmpPath = EditorUtils.GetProjectTempPath();

            EditorUtils.CheckDirectory(tmpPath);

            var assetBundleManifest = BuildPipeline.BuildAssetBundles(tmpPath, bab, bbo, target);


            var abNames = assetBundleManifest.GetAllAssetBundles();

            foreach (var abName in abNames)
            {
                string   tmpFileName    = Path.Combine(tmpPath, abName);
                string   targetFileName = Path.Combine(outPath, abName);
                FileInfo tInfo          = new FileInfo(targetFileName);
                if (tInfo.Exists)
                {
                    tInfo.Delete();
                }
                FileInfo fino = new FileInfo(tmpFileName);
                fino.CopyTo(targetFileName);
                Debug.LogFormat("Build assetbundle : {0} ", targetFileName);
            }
        }
示例#3
0
        public static void BuildAssetBundles()
        {
            CUtils.DebugCastTime("Time HandleUpdateMaterail End");
            EditorUtils.CheckstreamingAssetsPath();
            CUtils.DebugCastTime("Time CheckstreamingAssetsPath End");
            var ab = BuildPipeline.BuildAssetBundles(EditorUtils.GetOutPutPath(), SplitPackage.DefaultBuildAssetBundleOptions, target);

            SplitPackage.CreateStreamingFileManifest(ab);
            CUtils.DebugCastTime("Time BuildPipeline.BuildAssetBundles End");
        }