예제 #1
0
    public static void ExportABHashs(AssetBundleManifest mainfest, List <Frame.ABFile> abs = null)
    {
        bool save = abs == null;

        if (abs == null)
        {
            abs = abIndex.files;
        }

        abIndex.files.Clear();

        AssetDatabase.RemoveUnusedAssetBundleNames();
        var names = AssetDatabase.GetAllAssetBundleNames();

        ABNameDefineSet defineSet = GetNameDefineSet();

        List <string> garbages = new List <string>();

        foreach (var abName in names)
        {
            FileInfo fileInfo = new FileInfo(Frame.Helper.CombineWithSlash(GetABFloder(), abName));
            if (!fileInfo.Exists)
            {
                List <string> srcfiles = GetErrorABSource(abName);
                if (srcfiles.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var file in srcfiles)
                    {
                        sb.Append(string.Format("Error AB Define=>{0},", file));
                    }
                    BuildLog.WriteLine(sb.ToString());
                }
                garbages.Add(abName);
            }
            else
            {
                var info = new Frame.ABFile();
                info.name = abName;
                info.children.AddRange(mainfest.GetAllDependencies(abName));
                info.hash = mainfest.GetAssetBundleHash(abName).ToString();
                info.size = (int)fileInfo.Length;
                try {
                    info.persistent = defineSet.defineMap[abName].persistent;
                } catch (System.Exception ex) {
                    Debug.LogError(string.Format("Path Error! AB name:" + abName));
                }
                mABIndex.files.Add(info);
            }
        }

        if (save)
        {
            SaveABIndex();
        }
    }