UE 打包(使用ProjectLauncher,但是不修改源码达到自定义打包的效果)

文章介绍了两种方法:一是通过修改`Automation.cs`代码,在`BUILDSUCCESSFUL`消息后执行自定义操作;二是通过修改`RunUAT.bat`脚本,在运行UAT时调用自定义的`Packer.bat`。这两种方案涉及UE5项目构建过程中的自动化定制。
摘要由CSDN通过智能技术生成

方案一:使用UAT并修改Automation.cs代码
在打印BUILD SUCCESSFUL之后执行自定义的操作

App=D:\UEProject\UE5test\ue5test1\Packer.bat,CommandLine=D:\UEProject\UE5test\ue5test1

这行代码是放在ProjectLauncher->Build->Additional Command Line Parameters

CommandUtils.LogInformation("BUILD SUCCESSFUL");
for (int Index = 0; Index < CommandInfo.Arguments.Count; ++Index)
{
    string app = "";
    string commandLine = "";

    string argument = CommandInfo.Arguments[Index];

    // 提取 App 的值
    if (argument.Contains("App="))
    {
       int startIndex = argument.IndexOf("App=") + 4;
       int endIndex = argument.IndexOf(",", startIndex);
       if (endIndex != -1 && endIndex > startIndex)
       {
          app = argument.Substring(startIndex, endIndex - startIndex);
       }
    }

    // 提取 CommandLine 的值 
    if (argument.Contains("CommandLine="))
    {
       int startIndex = argument.IndexOf("CommandLine=") + 12;
       int endIndex = argument.IndexOf(",", startIndex);
       if (endIndex != -1 && endIndex > startIndex)
       {
          commandLine = argument.Substring(startIndex, endIndex - startIndex);
       }
    }

    CommandUtils.LogInformation("Custom CommandLine: {0},{1}", app, commandLine);
    if (!string.IsNullOrEmpty(app))
    {
       CommandUtils.Run(app, commandLine);
    }
}

方案二:修改RunUAT.bat

rem ## Run AutomationTool
:DoRunUAT
pushd %UATDirectory%
dotnet %UATExecutable% %*
:: 调取自定义的程序
:: call "D:\UEProject\UE5test\ue5test1\Packer.bat"
setlocal EnableDelayedExpansion
set "args=%*"
for /F "tokens=2 delims== " %%a in ("!args!") do (
    set "filePath=%%~dpa"
    echo !filePath!Packer.bat
    call "!filePath!Packer.bat"
)
endlocal
popd
set RUNUAT_ERRORLEVEL=%ERRORLEVEL%

对应批处理文件或exe程序内容可自定义

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dawn·张

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值