Last active
June 11, 2025 07:06
-
-
Save Solessfir/9e8a89a581e321649dfdc5027bcdaaad to your computer and use it in GitHub Desktop.
Unreal Engine Standalone Plugin Builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Copyright (c) Solessfir under MIT license | |
:: This batch file builds an Unreal Engine plugin for UE4 or UE5. | |
:: It locates a .uplugin file, extracts the EngineVersion, finds the Unreal Engine installation via registry, | |
:: and runs the AutomationTool to build the plugin for Win64. | |
:: If EngineVersion is missing, it displays an error and exits. | |
:: Save this file in your plugin's root directory and run it. | |
@echo off | |
title Build Plugin | |
setlocal EnableDelayedExpansion | |
:: Set root directory to the script's location | |
set "RootDirectory=%~dp0" | |
set "RootDirectory=%RootDirectory:~0,-1%" | |
:: Locate the .uplugin file | |
for %%i in ("%RootDirectory%\*.uplugin") do ( | |
set "UpluginFilePath=%%~i" | |
goto :UpluginLocationFound | |
) | |
cd .. | |
set "RootDirectory=%cd%" | |
for %%i in ("%RootDirectory%\*.uplugin") do ( | |
set "UpluginFilePath=%%~i" | |
goto :UpluginLocationFound | |
) | |
echo [91mError: No .uplugin file found in %RootDirectory% or its parent directory.[0m | |
goto :ExitWithPause | |
:UpluginLocationFound | |
echo Found .uplugin file: %UpluginFilePath% | |
:: Extract EngineVersion | |
set "EngineVersion=" | |
for /f "tokens=2 delims=: " %%a in ('findstr /i /c:"EngineVersion" "%UpluginFilePath%"') do ( | |
set "EngineVersion=%%a" | |
set "EngineVersion=!EngineVersion:~1,-2!" | |
) | |
:: Check if EngineVersion is missing or empty | |
if not defined EngineVersion ( | |
echo [91mError: EngineVersion is missing in %UpluginFilePath%. Cannot build the plugin.[0m | |
goto :ExitWithPause | |
) | |
if "!EngineVersion!"=="" ( | |
echo [91mError: EngineVersion is empty in %UpluginFilePath%. Cannot build the plugin.[0m | |
goto :ExitWithPause | |
) | |
:: Truncate to major.minor version (e.g., 5.5.4 -> 5.5) | |
for /f "tokens=1-2 delims=." %%a in ("!EngineVersion!") do ( | |
set "EngineVersion=%%a.%%b" | |
) | |
echo Using Engine Version: !EngineVersion! | |
:: Query registry for Unreal Engine installation directory | |
set "EngineDirectory=" | |
for /f "skip=2 tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\!EngineVersion!" /v "InstalledDirectory" 2^>nul') do ( | |
set "EngineDirectory=%%b" | |
) | |
if not defined EngineDirectory ( | |
echo [91mError: Couldn't find Unreal Engine installation for version !EngineVersion!.[0m | |
echo [93mEnsure Unreal Engine !EngineVersion! is installed via the Epic Games Launcher.[0m | |
goto :ExitWithPause | |
) | |
:: Set path to AutomationTool | |
set "AutomationToolPath=!EngineDirectory!\Engine\Build\BatchFiles\RunUAT.bat" | |
if not exist "!AutomationToolPath!" ( | |
echo [91mError: AutomationTool not found at !AutomationToolPath!.[0m | |
goto :ExitWithPause | |
) | |
echo Automation Tool Path: !AutomationToolPath! | |
echo: | |
:: Run the build command | |
echo Building plugin... | |
call "!AutomationToolPath!" BuildPlugin -Plugin="!UpluginFilePath!" -Package="!RootDirectory!\Build" -Rocket -TargetPlatforms=Win64 | |
:: Check build result | |
if !errorlevel! neq 0 ( | |
echo [91mError: Plugin build failed. Check the AutomationTool log for details.[0m | |
) else ( | |
echo [92mPlugin build completed successfully. Output in %RootDirectory%\Build[0m | |
) | |
:ExitWithPause | |
pause | |
exit /b 0 | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment