Beispiel #1
0
        public ABDiffInfo GenDiff(ABInfo other, string myNssUnityProj, string otherNssUnityProj)
        {
            ABDiffInfo abDiffInfo = new ABDiffInfo()
            {
                name   = name,
                kbSize = kbSize,
            };

            foreach (var myAssetInfo in m_lstTotalAsset)
            {
                var assetPath = myAssetInfo.path;
                if (!ExistsAsset(this, assetPath, myNssUnityProj))
                {
                    continue;
                }

                if (!ExistsAsset(other, assetPath, otherNssUnityProj))
                {// 自己有,别人没有,为新增
                    abDiffInfo.AddDiffAsset(ABDiffInfo.DiffType.Add, assetPath);
                }
                else
                {// 都有,检查是否修改
                    var myAssetLocalPath    = Path.Combine(myNssUnityProj, assetPath);
                    var otherAssetLocalPath = Path.Combine(otherNssUnityProj, assetPath);

                    if (CheckLocalAssetChange(myAssetLocalPath, otherAssetLocalPath))
                    {
                        abDiffInfo.AddDiffAsset(ABDiffInfo.DiffType.Mod, assetPath);
                    }
                }
            }

            foreach (var otherAssetInfo in other.m_lstTotalAsset)
            {
                var assetPath = otherAssetInfo.path;

                if (!ExistsAsset(other, assetPath, otherNssUnityProj))
                {
                    continue;
                }

                if (!ExistsAsset(this, assetPath, myNssUnityProj))
                {// 别人有,自己没有,为删除
                    abDiffInfo.AddDiffAsset(ABDiffInfo.DiffType.Del, otherAssetInfo.path);
                }
            }
            return(abDiffInfo);
        }
Beispiel #2
0
        private static void StatAddAssets(
            string pathAssetInfoData1,
            string pathBundleNodeData1,
            string nssUnityProjDir1,
            string nssUnityProjDir2,
            string pathABList,
            string outfile)
        {
            var abAssetRelation1 = new ABAssetRelation();

            abAssetRelation1.Parse(pathAssetInfoData1, pathBundleNodeData1, nssUnityProjDir1);

            Logger.Log("计算资源差异...");
            List <ABDiffInfo>         abDiffInfos = new List <ABDiffInfo>();
            Dictionary <string, bool> dicAB       = new Dictionary <string, bool>();

            foreach (var line in File.ReadAllLines(pathABList))
            {
                var abName = line.Split(' ', '\t')[0].Replace("AssetBundles/", "");

                var ab = abAssetRelation1.GetAB(abName);
                if (abDiffInfos.Find(item => item.name == abName) != null)
                {
                    throw new Exception($"重复的ab: {ab.name}");
                }

                var abDiffInfo = new ABDiffInfo()
                {
                    name = abName
                };
                foreach (var assetInfo in ab.EnumTotalAssets())
                {
                    var assetPath2 = Path.Combine(nssUnityProjDir2, assetInfo.path);
                    if (!File.Exists(assetPath2))
                    {
                        abDiffInfo.AddDiffAsset(ABDiffInfo.DiffType.Add, assetInfo.path);
                    }
                    else
                    {
                        if (FileUtil.ComputeSHA1(Path.Combine(nssUnityProjDir1, assetInfo.path)) != FileUtil.ComputeSHA1(assetPath2))
                        {
                            abDiffInfo.AddDiffAsset(ABDiffInfo.DiffType.Mod, assetInfo.path);
                        }
                    }
                }


                abDiffInfos.Add(abDiffInfo);
            }

            Logger.Log("输出...");
            using (var f = new StreamWriter(outfile))
            {
                foreach (var abDiffInfo in abDiffInfos)
                {
                    f.WriteLine(abDiffInfo.name);
                    foreach (var asset in abDiffInfo.EnumDiffAssets())
                    {
                        f.WriteLine($"    {asset.Value}|{asset.Key}");
                    }
                }
            }

            //using (var f = new FileStream(outfile, FileMode.Create))
            //{
            //    BinaryFormatter binaryFormatter = new BinaryFormatter();
            //    binaryFormatter.Serialize(f, abAssetRelation);
            //}
        }