Esempio n. 1
0
    static void AddBundleInfo(string bundleName, ref FileList filelist)
    {
        if (string.IsNullOrEmpty(bundleName))
        {
            return;
        }

        string bundlePath = string.Format("{0}/{1}", PackAssetBundle.bundleBuildFolder, bundleName);

        uint crc = 0;

        if (!BuildPipeline.GetCRCForAssetBundle(bundlePath, out crc))
        {
            return;
        }

        FileInfo fileInfo = new FileInfo(bundlePath);
        UInt32   size     = (UInt32)fileInfo.Length;
        string   md5      = "";

        if (string.Equals(bundleName, ResourceConst.PkgBundleFolder))
        {
            md5 = MD5Utils.GetMD5(bundlePath);
        }
        else
        {
            md5 = FileDepencies.GetBundleMD5(bundlePath);
        }

        filelist.AddBundleInfo(bundleName, crc, size, md5);
    }
Esempio n. 2
0
    static void DisposeSingleScene(string scenPath)
    {
        if (string.IsNullOrEmpty(scenPath))
        {
            return;
        }

        string bundleName = string.Empty;

        // 打包依赖忽略文件;
        string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenPath);

        string[] deps = AssetDatabase.GetDependencies(scenPath);
        FileDepencies.AddDepencies(scenPath, deps);
        if (deps != null)
        {
            for (int i = 0; i < deps.Length; i++)
            {
                string dep = deps[i];
                if (PackAssetBundleUtlis.IsFilterSceneRes(dep, scenPath))
                {
                    continue;
                }

                bundleName = PackAssetBundleUtlis.GetBundleName(dep);
                _packTools.PushAssetBuild(dep, bundleName, false);
            }
        }

        //打场景本身;
        bundleName = PackAssetBundleUtlis.GetBundleName(scenPath, "scenes");
        _packTools.PushAssetBuild(scenPath, bundleName);
    }
Esempio n. 3
0
    static void Clear()
    {
        _packTools.Clear();
        ClearAllOtherFile();

        FileDepencies.Clear();
    }
Esempio n. 4
0
    public static void BuildFileList(bool show_dialog)
    {
        Clear();

        DateTime dt1 = System.DateTime.UtcNow;
        // 获取AssetBundleManifest;
        string manifestPath          = string.Format("{0}/{1}", PackAssetBundle.bundleBuildFolder, ResourceConst.PkgBundleFolder);
        AssetBundleManifest manifest = PackBundleTools.GetAssetBundleManifest(manifestPath);

        if (manifest == null)
        {
            return;
        }

        // 计算总控文件;
        AddBundleInfo(ResourceConst.PkgBundleFolder, ref s_FileList);

        // 计算Config;
        AddConfInfo(s_FileList);

        // 计算其它文件;
        string[] allBundleKeyList = manifest.GetAllAssetBundles();
        for (int i = 0; i < allBundleKeyList.Length; i++)
        {
            string file = allBundleKeyList[i];
            if (string.IsNullOrEmpty(file))
            {
                continue;
            }
            AddBundleInfo(file, ref s_FileList);

            PackAssetBundleUtlis.ShowProgress(i, allBundleKeyList.Length, "计算MD5:", file);
        }
        EditorUtility.ClearProgressBar();

        string   strFileList = string.Format("{0}.txt", ResourceConst.FileListName);
        DateTime dt2         = System.DateTime.UtcNow;

        BuildCommon.WriteJsonToFile(PackAssetBundle.bundleBuildFolder, strFileList, s_FileList);

        FileDepencies.WriteMd5Info();

        DateTime dt3 = System.DateTime.UtcNow;

        BuildFileListAssetBundle(PackAssetBundle.bundleBuildFolder, strFileList, ResourceConst.FileListName);

        DateTime dt4 = System.DateTime.UtcNow;

        if (show_dialog)
        {
            string info = string.Format("FileList生成完成,总时长{0}秒", (dt4 - dt1).TotalSeconds.ToString("f1"));
            EditorUtility.DisplayDialog("打包完成", info, "好的");
        }
    }
Esempio n. 5
0
    static void DisposeAsset(string path, bool check_dep = true)
    {
        if (string.IsNullOrEmpty(path))
        {
            return;
        }

        if (PackAssetBundleUtlis.IsFilterAsset(path))
        {
            return;
        }
        string bundleName = string.Empty;

        if (check_dep)
        {
            // 分析依赖;
            string[] deps = AssetDatabase.GetDependencies(path);
            FileDepencies.AddDepencies(path, deps);
            if (deps != null)
            {
                for (int i = 0; i < deps.Length; i++)
                {
                    string dep = deps[i];
                    if (PackAssetBundleUtlis.IsFilterAssetDep(dep, path))
                    {
                        continue;
                    }

                    bundleName = PackAssetBundleUtlis.GetBundleName(dep);
                    _packTools.PushAssetBuild(dep, bundleName, false);
                }
            }
        }

        // 添加Asset自身;
        bundleName = PackAssetBundleUtlis.GetBundleName(path);
        _packTools.PushAssetBuild(path, bundleName);
    }