コード例 #1
0
    /// <summary>
    /// 更新runtime的资源
    /// </summary>
    /// <param name="ResModifList">资源列表</param>
    /// <param name="ResDeleteList">其他列表</param>
    /// <param name="needToExportFile">是否需要导出文件,如果为true的话,会调用ExportPackageListToRunTime</param>
    /// <returns>更新后的资源列表</returns>
    private static Dictionary <string, AssetBundleManager.PackageNode> UpdateRunTime_Res(List <string> ResModifList, List <string> ResDeleteList, bool needToExportFile = false)
    {
        string runTimeAssetPcakagePath = GetRunTimeAssetPackagePatchRoot();
        Dictionary <string, AssetBundleManager.PackageNode> runTimeResFileList    = new Dictionary <string, AssetBundleManager.PackageNode>();
        Dictionary <string, AssetBundleManager.PackageNode> runTimeOhterFilerList = new Dictionary <string, AssetBundleManager.PackageNode>();;

        EditorLog.LogInfo("正在进行资源文件加密....", true);
        //加载runtime的进来
        AssetBundleManager.ForceOpenDeCode = true;
        AssetBundleManager.LoadPackageList(GetRunTimeAssetPackagePatchRoot() + AssetBundleManager.AssetPackageListPatch, runTimeResFileList, runTimeOhterFilerList);
        AssetBundleManager.ForceOpenDeCode = false;

        if (null == ResModifList)
        {
            return(runTimeResFileList);
        }
        if (ResModifList.Count <= 0)
        {
            return(runTimeResFileList);
        }

        if (!IsEnableMultThread())
        {
            ProcessEncodeFileNode(PackageNodeType.AssetsBundleFile, ResModifList, ref runTimeResFileList);
        }
        else
        {
            List <EncodeFileNode> AsyncList = DispatchEncodeFileNode(PackageNodeType.AssetsBundleFile, ResModifList, runTimeResFileList, AssetBundleManager.MaxActiveThread);

            while (!IsEncodeFileFinish(AsyncList))
            {
                ;
            }

            CombineEncodeFileTable(ref runTimeResFileList, AsyncList);
        }

        if (null != ResDeleteList)
        {
            foreach (string str in ResDeleteList)
            {
                if (runTimeResFileList.ContainsKey(str))
                {
                    runTimeResFileList.Remove(str);
                }
            }
        }


        if (needToExportFile)
        {
            ExportPackageListToRunTime(runTimeResFileList, runTimeOhterFilerList);
        }

        runTimeOhterFilerList.Clear();
        return(runTimeResFileList);
    }
コード例 #2
0
    /// <summary>
    /// 全部加密一遍
    /// </summary>
    private static void EncodeFile_All(Dictionary <string, AssetBundleManager.PackageNode> ResFileList, Dictionary <string, AssetBundleManager.PackageNode> OtherFileList, bool debugvision)
    {
        List <string> tempList = new List <string>();

        #region Res
        EditorLog.LogInfo("正在进行资源文件加密....", true);
        tempList.AddRange(ResFileList.Keys);
        if (!IsEnableMultThread())
        {
            ProcessEncodeFileNode(PackageNodeType.AssetsBundleFile, tempList, ref ResFileList);
        }
        else
        {
            List <EncodeFileNode> AsyncList = DispatchEncodeFileNode(PackageNodeType.AssetsBundleFile, tempList, ResFileList, AssetBundleManager.MaxActiveThread);

            while (!IsEncodeFileFinish(AsyncList))
            {
                ;
            }

            CombineEncodeFileTable(ref ResFileList, AsyncList);
        }
        #endregion

        #region other
        EditorLog.LogInfo("正在进行代码、配置文件加密....", true);
        tempList.Clear();
        tempList.AddRange(OtherFileList.Keys);

        if (!IsEnableMultThread())
        {
            ProcessEncodeFileNode(PackageNodeType.OtherFile, tempList, ref OtherFileList);
        }
        else
        {
            List <EncodeFileNode> AsyncList = DispatchEncodeFileNode(PackageNodeType.OtherFile, tempList, OtherFileList, AssetBundleManager.MaxActiveThread);

            while (!IsEncodeFileFinish(AsyncList))
            {
                ;
            }

            CombineEncodeFileTable(ref OtherFileList, AsyncList);
        }
        #endregion
        ExportPackageListToRunTime(ResFileList, OtherFileList);
    }
コード例 #3
0
    private static void GenerateErrorFile(string overrideCopyEditorLogPath)
    {
        string LogPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Unity\\Editor\\Editor.log";

        if (EditorRunTypeWindow.IsRunFromCommandLine)
        {
            string[] allCommandLine = Environment.GetCommandLineArgs();
            for (int i = 0; i < allCommandLine.Length; i++)
            {
                if (allCommandLine[i].Contains("-logFile"))
                {
                    LogPath = allCommandLine[i + 1];
                    EditorLog.LogInfo("findCommandLineLogPath:" + LogPath, true);
                    break;
                }
            }
        }
        string reladyCopyPath = CopyLogPath;

        if (!string.IsNullOrEmpty(overrideCopyEditorLogPath))
        {
            reladyCopyPath = overrideCopyEditorLogPath;
        }
        File.Copy(LogPath, reladyCopyPath, true);

        string reader = File.ReadAllText(reladyCopyPath);

        reader = reader.Replace("\r", string.Empty);
        string[] lines = reader.Split('\n');
        foreach (string line in lines)
        {
            FixedPathNode reslut = GetNeedToFixedPath(line);
            if (null != reslut)
            {
                if (reslut.FixedPath.Contains(".dll"))
                {
                    needtoFixDll = true;
                }
                else
                {
                    needToFixedFilePath.Add(reslut);
                }
            }
        }
    }
コード例 #4
0
    /// <summary>
    /// 项目发布完成后
    /// </summary>
    /// <returns></returns>
    private static void OnPostBuildProject(bool debugVersion, bool forceEncodeFile, bool Is64bit)
    {
        EditorLog.LogInfo("正在计算发布后的文件差异....", true);
        GenerateOtherInfo(debugVersion, Is64bit);

        List <string> OtherModifList  = null;
        List <string> OtherDeleteList = null;

        ReadDetailFile(GetOtherDetailFileNamePath(), ref OtherModifList, ref OtherDeleteList);

        //资源文件需要读进来,因为是发布前生成的
        List <string> ResModifList  = null;
        List <string> ResDeleteList = null;

        ReadDetailFile(GetResDetailFileNamePath(), ref ResModifList, ref ResDeleteList);

        EditorLog.LogInfo("正在备份发布文件....", true);
        string BackUpFileFloder = "PackingFileBackUp/";

        BackUpFileFloder += DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "/";

        BackUpFiles_First(BackUpFileFloder);

        Dictionary <string, AssetBundleManager.PackageNode> NewResFileList   = new Dictionary <string, AssetBundleManager.PackageNode>();
        Dictionary <string, AssetBundleManager.PackageNode> NewOtherFileList = new Dictionary <string, AssetBundleManager.PackageNode>();

        AssetBundleManager.LoadPackageList(GetEditorAssetPackagePatchRoot() + AssetBundleManager.AssetPackageListPatch, NewResFileList, NewOtherFileList);

        CorrectRunTimeAssetFile(NewResFileList);

        EncodeFile(NewResFileList, NewOtherFileList, ResModifList, ResDeleteList, OtherModifList, OtherDeleteList, debugVersion, forceEncodeFile);

        NewResFileList.Clear();
        NewOtherFileList.Clear();

        DeleteFileHelper(GetResDetailFileNamePath());
        DeleteFileHelper(GetOtherDetailFileNamePath());
        BackUpFiles_Second(BackUpFileFloder);
    }
コード例 #5
0
    void OnFlow_OnBuildingEXE(bool isDebug, bool is64bit)
    {
        ReleaseBuildingEXECommand();

        if (isDebug)
        {
            EditorLog.StartLog("BuildProjectLog", EditorLog.LogLevel.ERROR);
            //备份文件
            CopyFileHelper(GetClient_GamePathRoot() + ResDetailFileName, GetBuildFlowFloderPathRoot() + ResDetailFileName);

            //告知流程--告知崩溃,如果没有崩溃,后面会删除
            CreateFileHelper(GetBuildProjectCarshFlagsPath());

            OnBuildProjectStart();

            BuildProject_Impl(isDebug, is64bit);

            if (EditorLog.isHaveFatleErrorLog)
            {
                OnBuildProjectFaild();
                EditorLog.EndLog();
                if (!File.Exists(GetRunFromOutSideProgramPath()))
                {
                    EditorUtility.DisplayDialog("致命错误", "!!!!!!Debug版本有致命错误,不能进行后续操作!!!!!!稍后会打开对应的日志路径,请将:" + EditorLog.LogPath + "发给程序.", "确定");
                    System.Diagnostics.Process.Start(Path.GetDirectoryName(EditorLog.LogPath));
                }
                OnFlow_BuildingExeFailed(isDebug, is64bit);
            }
            else if (EditorLog.isHaveErroLog)
            {
                OnBuildProjectFaild();
                EditorLog.EndLog();
                if (!File.Exists(GetRunFromOutSideProgramPath()))
                {
                    EditorUtility.DisplayDialog("发布错误", "Debug版本发布错误,稍后会打开对应的日志路径,请将:" + EditorLog.LogPath + "发给程序.", "确定");
                    System.Diagnostics.Process.Start(Path.GetDirectoryName(EditorLog.LogPath));
                }
                OnFlow_BuildingExeFailed(isDebug, is64bit);
            }
            else
            {
                OnBuildProjectSuccess();
                OnFlow_BuildingExeSuccess(isDebug, is64bit);
                EditorLog.LogInfo("工程发布成功!!!!!!!!!!!!!!!!", true);
            }
            EditorLog.EndLog();
        }
        else
        {
            EditorLog.StartLog("BuildProjectLog", EditorLog.LogLevel.ERROR);
            OnBuildProjectStart();
            CopyFileHelper(GetClient_GamePathRoot() + ResDetailFileName, GetBuildFlowFloderPathRoot() + ResDetailFileName);

            BuildProject_Impl(isDebug, is64bit);

            if (EditorLog.isHaveFatleErrorLog)
            {
                OnBuildProjectFaild();

                EditorLog.EndLog();
                if (!File.Exists(GetRunFromOutSideProgramPath()))
                {
                    EditorUtility.DisplayDialog("致命错误", "!!!Release版本有致命错误,不能进行后续操作!!!稍后会打开对应的日志路径,请将:" + EditorLog.LogPath + "发给程序.", "确定");
                    System.Diagnostics.Process.Start(Path.GetDirectoryName(EditorLog.LogPath));
                }
                OnFlow_BuildingExeFailed(isDebug, is64bit);
            }
            else if (EditorLog.isHaveErroLog)
            {
                OnBuildProjectFaild();

                EditorLog.EndLog();
                if (!File.Exists(GetRunFromOutSideProgramPath()))
                {
                    EditorUtility.DisplayDialog("发布错误", "Release版本发布错误,稍后会打开对应的日志路径,请将:" + EditorLog.LogPath + "发给程序.", "确定");
                    System.Diagnostics.Process.Start(Path.GetDirectoryName(EditorLog.LogPath));
                }
                OnFlow_BuildingExeFailed(isDebug, is64bit);
            }
            else
            {
                OnBuildProjectSuccess();

                OnFlow_BuildingExeSuccess(isDebug, is64bit);
                EditorLog.LogInfo("工程发布成功!!!!!!!!!!!!!!!!", true);
            }
            EditorLog.EndLog();
        }
    }
コード例 #6
0
    public static void BuildFullPackage_Impl(bool Version_64Bit)
    {
        if (!Is64bitEditor)
        {
            Debug.LogError("发布只能使用64位编辑器");
            return;
        }
        //if (!Is64BitNativeDll("game.dll") && Version_64Bit)
        //{
        //    Debug.LogError("NativeDLL不是64位版本");
        //    return;
        //}
        //if (Is64BitNativeDll("game.dll") && !Version_64Bit)
        //{
        //    Debug.LogError("NativeDLL不是32位版本");
        //    return;
        //}

        //DestroyAllBuiltInMaterial();
        //DestroyAllBuiltInShader();
        isBuildingPackage = true;
        Console.Clear();

        SaveAndRefershAssets();

        Dictionary <string, AssetBundleManager.PackageNode> OldResFileList   = new Dictionary <string, AssetBundleManager.PackageNode>();
        Dictionary <string, AssetBundleManager.PackageNode> OldOtherFileList = new Dictionary <string, AssetBundleManager.PackageNode>();

        //打包之前,先吧资源列表加载进来,后面用于做更新对比
        AssetBundleManager.LoadPackageList(GetEditorAssetPackagePatchRoot() + AssetBundleManager.AssetPackageListPatch, OldResFileList, OldOtherFileList);

        /*
         * 先生成预制体配置,因为有的资源再导入之前是没有assetbundle的
         */
        EditorLog.LogInfo("正在计算预制体信息....", true);
        if (BuildPrePrefabConfig || BuildAll)
        {
            PreGeneratePrefabConfig();
            SaveAndRefershAssets();
        }

        if (BuildPacakage || BuildAll)
        {
            EditorLog.LogInfo("正在打包资源文件....", true);

            if (!System.IO.Directory.Exists(AssetBundleManager.FullAssetPackagePathRoot) && !File.Exists(AssetBundleManager.FullAssetPackagePathRoot))
            {
                System.IO.Directory.CreateDirectory(AssetBundleManager.FullAssetPackagePathRoot);
            }

            BuildPipeline.BuildAssetBundles(AssetBundleManager.FullAssetPackagePathRoot, BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.DeterministicAssetBundle, Version_64Bit ? BuildTarget.StandaloneWindows64 : BuildTarget.StandaloneWindows);
            SaveAndRefershAssets();
        }



        BuildCurrAssetBundleList();

        if (BuildUIConfig || BuildAll)
        {
            EditorLog.LogInfo("正在计算UI配置....", true);
            GenerateUIConfig();
        }
        if (BuildSceneConfig || BuildAll)
        {
            EditorLog.LogInfo("正在计算场景配置....", true);
            GenerateScenConfig();
        }

        if (BuildScheme || BuildAll)
        {
            EditorLog.LogInfo("正在计算Scheme....", true);
            GenerateScheme();
            ExportLightingEffectConfig();
        }

        if (BuildPostPrefabConfig || BuildAll)
        {
            EditorLog.LogInfo("正在合并资源文件....", true);
            PostGeneratePrefabConfig();
        }

        if (BuildAssetsInfo || BuildAll)
        {
            EditorLog.LogInfo("正在计算资源信息....", true);
            GenerateEditorAssetInfo(OldResFileList, OldOtherFileList);
        }

        SaveAndRefershAssets();
        //DeleteMainfainstFile(GetEditorAssetPackagePatchRoot());
        isBuildingPackage = false;

        EditorLog.LogInfo("正在修复打包错误文件...", true);

        if (AssetBundleImporterFixedEditor.DoImporterFixed("CopyEditorLog_BuildPackage.log", "FixedFillPathInfo_BuildPackage.txt"))
        {
            foreach (AssetBundleImporterFixedEditor.FixedPathNode path in AssetBundleImporterFixedEditor.FixedFilePath)
            {
                EditorLog.LogInfo("修复文件成功:" + path.getDesc() + ",可重新打包或者下次打包...", true);
            }

            CreateFileHelper(GetCommand_NeedToRePackingAssets());
        }
        else
        {
            EditorLog.LogInfo("没有发现需要修复的文件...", true);
        }
    }