Example #1
0
    /**
     * Build bundles.
     */
    public static void BuildBundles(string[] bundles)
    {
        Dictionary <string, List <string> > buildingRoutes = new Dictionary <string, List <string> >();

        foreach (string bundle in bundles)
        {
            AddBundleToBuildList(bundle, ref buildingRoutes);
        }
        m_BuiltCount = 0;
        var startTime = Time.realtimeSinceStartup;

        foreach (var buildRoute in buildingRoutes)
        {
            BundleData bundle = BundleManager.GetBundleData(buildRoute.Key);
            if (bundle != null)
            {
                BuildBundleTree(bundle, buildRoute.Value);
            }
        }

        BMDataAccessor.BuildVersion++;
        BMDataAccessor.SaveBundleBuildVersion();
        BMDataAccessor.SaveBundleVersionInfo();

        string exportpath = BuildConfiger.InterpretedOutputPath;

        if (!Directory.Exists(exportpath))
        {
            Directory.CreateDirectory(exportpath);
        }

        BundleManager.UpdateAllBundlesNeedBuild();

        uint crc = 0;

        if (!BuildAssetBundle(new string[] { BMDataAccessor.BundleBuildVersionPath, BMDataAccessor.BMConfigerPath }, Path.Combine(exportpath, "BM.data"), out crc))
        {
            //存入数据,三个path指向三个txt文件,将三个txt文件导入BM.data
            Debug.LogError("Failed to build bundle of config files.");
        }
        Debug.Log("Build bundles:" + m_BuiltCount + "| AssetBundleVersion:" + BMDataAccessor.BuildVersion + "| Time Consumed" + (Time.realtimeSinceStartup - startTime));

        File.WriteAllText(Path.Combine(exportpath, "BMDataVersion.txt"), BMDataAccessor.BuildVersion.ToString());
    }