Example #1
0
    private static void GeneratePackageNode(PackageNodeType packageType, string path, ref Dictionary <string, AssetBundleManager.PackageNode> resultTable,
                                            string ignorePackageNameStr)
    {
        AssetFileInfo info = GetFileInfo(path);

        if (null == info)
        {
            return;
        }
        if (null == resultTable)
        {
            resultTable = new Dictionary <string, AssetBundleManager.PackageNode>();
        }

        AssetBundleManager.PackageNode nod = new AssetBundleManager.PackageNode();

        string packName = path.Replace("\\", "/");

        packName = packName.Replace(ignorePackageNameStr, string.Empty);


        nod.md5 = info.md5;
        nod.assetBundlePatch = packName;
        nod.fileSize         = info.fileLengthInMB;

        if (packageType == PackageNodeType.AssetsBundleFile)
        {
            /*
             * 对已经不用的资源包进行删除操作
             */
            if (!IsConfigFile(path) && !IsOnAssetBundle(packName) && !path.EndsWith(AssetBundleManager.PrefabUnionVariant))
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                    if (File.Exists(path + ".meta"))
                    {
                        File.Delete(path + ".meta");
                    }

                    if (File.Exists(path + ".manifest"))
                    {
                        File.Delete(path + ".manifest");

                        if (File.Exists(path + ".manifest" + ".meta"))
                        {
                            File.Delete(path + ".manifest" + ".meta");
                        }
                    }
                }
                return;
            }
        }

        if (!path.Contains(AssetBundleManager.PrefabVariant))
        {
            resultTable.Add(packName, nod);
        }
    }
Example #2
0
    private static void ProcessEncodeFileNode(PackageNodeType packageType, string ModifPath, ref Dictionary <string, AssetBundleManager.PackageNode> resultTable)
    {
        if (packageType == PackageNodeType.AssetsBundleFile)
        {
            string s           = AssetBundleManager.FullAssetPackagePathRoot + ModifPath;
            string RunTimePath = GetRunTimeAssetPackagePatchRoot() + ModifPath;

            //配置文件直接
            if (IsConfigFile(s))
            {
                EnCodeAssetConfigFileHelper(s, RunTimePath);
            }
            else
            {
                EnCodeAssetFileHelper(s, RunTimePath);
            }
            AssetFileInfo info = GetFileInfo(RunTimePath);
            if (null == info)
            {
                return;
            }

            if (info.fileLengthInBytes <= 0)
            {
                EditorLog.LogFatleError("文件为空:" + RunTimePath);
                return;
            }

            AssetBundleManager.PackageNode nod;
            if (resultTable.TryGetValue(ModifPath, out nod))
            {
                nod.md5                = info.md5;
                nod.fileSize           = info.fileLengthInMB;
                resultTable[ModifPath] = nod;
            }
            else
            {
                nod     = new AssetBundleManager.PackageNode();
                nod.md5 = info.md5;
                nod.assetBundlePatch = ModifPath;
                nod.fileSize         = info.fileLengthInMB;
                resultTable.Add(ModifPath, nod);
            }
        }
        else if (packageType == PackageNodeType.OtherFile)
        {
            string s = GetRunTimeBinPatchRoot() + ModifPath;

            //只对C#的代码进行加密
            if (IsManagedScript(s))
            {
                EnCodeScriptHelper(s, s);
            }


            AssetFileInfo info = GetFileInfo(s);
            if (null == info)
            {
                return;
            }
            if (info.fileLengthInBytes <= 0)
            {
                EditorLog.LogFatleError("文件为空:" + s);
                return;
            }
            AssetBundleManager.PackageNode nod;
            if (resultTable.TryGetValue(ModifPath, out nod))
            {
                nod.md5                = info.md5;
                nod.fileSize           = info.fileLengthInMB;
                resultTable[ModifPath] = nod;
            }
            else
            {
                nod     = new AssetBundleManager.PackageNode();
                nod.md5 = info.md5;
                nod.assetBundlePatch = ModifPath;
                nod.fileSize         = info.fileLengthInMB;
                resultTable.Add(ModifPath, nod);
            }
        }
    }