Last active
April 14, 2026 21:55
-
-
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 | |
| :: Place it near .uplugin file and run it | |
| @echo off | |
| setlocal EnableDelayedExpansion | |
| title Build Plugin | |
| :: Enable ANSI color support | |
| reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1 /f >nul 2>&1 | |
| :: Define Colors | |
| for /f "delims=" %%a in ('powershell -NoProfile -Command "[char]27"') do set "ESC=%%a" | |
| set "Colors_Red=!ESC![91m" | |
| set "Colors_Green=!ESC![92m" | |
| set "Colors_White=!ESC![97m" | |
| set "Colors_Reset=!ESC![0m" | |
| :: Configuration | |
| set "RootDirectory=%~dp0" | |
| set "RootDirectory=%RootDirectory:~0,-1%" | |
| set "TargetPlatform=Win64" | |
| set "PushdDone=0" | |
| :: 1. Locate Plugin | |
| if exist "%RootDirectory%\*.uplugin" ( | |
| set "PluginDir=%RootDirectory%" | |
| ) else if exist "%RootDirectory%\..\*.uplugin" ( | |
| set "PluginDir=%RootDirectory%\.." | |
| ) else ( | |
| echo !Colors_Red!Error: No .uplugin file found.!Colors_Reset! | |
| goto :ExitWithPause | |
| ) | |
| pushd "%PluginDir%" | |
| set "PushdDone=1" | |
| for %%i in ("*.uplugin") do set "UpluginFile=%%~fi" & set "PluginName=%%~ni" | |
| :: 2. Extract Engine Version | |
| set "RawVersion=" | |
| for /f "tokens=2 delims=:" %%a in ('findstr /i "EngineVersion" "%UpluginFile%"') do set "RawVersion=%%a" | |
| :: Clean string (remove quotes, spaces, commas) | |
| if defined RawVersion ( | |
| set "RawVersion=!RawVersion:"=!" | |
| set "RawVersion=!RawVersion:,=!" | |
| set "RawVersion=!RawVersion: =!" | |
| ) else ( | |
| echo !Colors_White!EngineVersion not found in .uplugin - searching for latest installed Unreal Engine...!Colors_Reset! | |
| set "LatestShortVersion=" | |
| for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\EpicGames\Unreal Engine" 2^>nul ^| findstr /r "\\[0-9]"') do ( | |
| set "FullKey=%%a" | |
| set "LatestShortVersion=!FullKey:HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\=!" | |
| ) | |
| if defined LatestShortVersion ( | |
| set "RawVersion=!LatestShortVersion!" | |
| echo Using: !Colors_White!!RawVersion!!Colors_Reset! | |
| ) else ( | |
| echo !Colors_Red!Error: No Unreal Engine installation found.!Colors_Reset! | |
| goto :ExitWithPause | |
| ) | |
| ) | |
| :: 3. Locate Engine Installation | |
| set "EngineDir=" | |
| :: A. Try exact match (Source Builds/GUIDs via HKCU) | |
| reg query "HKCU\Software\Epic Games\Unreal Engine\Builds" /v "{%RawVersion%}" >nul 2>&1 | |
| if !errorlevel! equ 0 ( | |
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Epic Games\Unreal Engine\Builds" /v "{%RawVersion%}"') do set "EngineDir=%%b" | |
| ) | |
| :: B. Try Standard Installation (HKLM) - Requires Major.Minor format (e.g. 5.3) | |
| if not defined EngineDir ( | |
| :: Parse Major.Minor from the raw version (e.g., 5.3.2 -> 5.3) | |
| for /f "tokens=1,2 delims=." %%a in ("!RawVersion!") do set "ShortVersion=%%a.%%b" | |
| reg query "HKLM\SOFTWARE\EpicGames\Unreal Engine\!ShortVersion!" /v "InstalledDirectory" >nul 2>&1 | |
| if !errorlevel! equ 0 ( | |
| for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\EpicGames\Unreal Engine\!ShortVersion!" /v "InstalledDirectory"') do set "EngineDir=%%b" | |
| ) | |
| ) | |
| :: C. Check Relative Path | |
| :: EngineDir must be set to the engine root (parent of the Engine\ folder) so the | |
| :: RunUAT path below resolves correctly as %EngineDir%\Engine\Build\BatchFiles\RunUAT.bat | |
| if not defined EngineDir ( | |
| if exist "%PluginDir%\..\..\Engine\Build\BatchFiles\RunUAT.bat" set "EngineDir=%PluginDir%\..\.." | |
| ) | |
| if not defined EngineDir ( | |
| echo !Colors_Red!Error: Unreal Engine installation not found for version: %RawVersion%!Colors_Reset! | |
| goto :ExitWithPause | |
| ) | |
| set "RunUAT=%EngineDir%\Engine\Build\BatchFiles\RunUAT.bat" | |
| if not exist "!RunUAT!" ( | |
| echo !Colors_Red!Error: RunUAT.bat not found at:!Colors_Reset! | |
| echo !RunUAT! | |
| goto :ExitWithPause | |
| ) | |
| :: 4. Locate Host Project (.uproject two levels up - optional, needed to resolve external plugin dependencies) | |
| set "UprojectFile=" | |
| for %%i in ("%PluginDir%\..\..\*.uproject") do set "UprojectFile=%%~fi" | |
| :: 5. Build Plugin | |
| cls | |
| echo !Colors_Green!:: Building Plugin: %PluginName% ::!Colors_Reset! | |
| echo Version: !Colors_White!%RawVersion%!Colors_Reset! | |
| echo Engine: !Colors_White!%EngineDir%!Colors_Reset! | |
| if defined UprojectFile ( | |
| echo Project: !Colors_White!%UprojectFile%!Colors_Reset! | |
| ) | |
| echo: | |
| set "OutputDir=%PluginDir%\Build" | |
| :: Clean previous build | |
| if exist "%OutputDir%" ( | |
| echo Cleaning previous build... | |
| rd /s /q "%OutputDir%" >nul 2>&1 | |
| ) | |
| :: Execute build: | |
| :: - With host project: UAT BuildPlugin isolates the plugin but cannot compile external plugin | |
| :: dependencies in its restricted HostProject environment. Use Build.bat against the real | |
| :: project instead (all deps resolve naturally), then package the output manually. | |
| :: - Standalone: UAT BuildPlugin works fine for self-contained plugins. | |
| if defined UprojectFile ( | |
| set "BuildBat=%EngineDir%\Engine\Build\BatchFiles\Build.bat" | |
| call "!BuildBat!" UnrealEditor Win64 Development -Project="%UprojectFile%" -plugin="%UpluginFile%" -noubtmakefiles -nohotreload | |
| set "BuildResult=!errorlevel!" | |
| if !BuildResult! equ 0 ( | |
| echo: | |
| echo Packaging... | |
| robocopy "%PluginDir%" "%OutputDir%" /E /XD "Source" /XD "Intermediate" /XD "Build" /XF "*.pdb" /XF "*.bat" /NJH /NJS >nul | |
| ) | |
| ) else ( | |
| call "!RunUAT!" BuildPlugin -Plugin="%UpluginFile%" -Package="%OutputDir%" -Rocket -TargetPlatforms=%TargetPlatform% | |
| set "BuildResult=!errorlevel!" | |
| :: Clean up temp HostProject from the output package | |
| if exist "%OutputDir%\HostProject" ( | |
| rd /s /q "%OutputDir%\HostProject" >nul 2>&1 | |
| ) | |
| ) | |
| echo: | |
| if !BuildResult! neq 0 ( | |
| echo !Colors_Red!Build Failed. Check log above.!Colors_Reset! | |
| ) else ( | |
| echo !Colors_Green!Build Successful.!Colors_Reset! | |
| echo Output: !Colors_White!%OutputDir%!Colors_Reset! | |
| ) | |
| :ExitWithPause | |
| if "%PushdDone%"=="1" popd | |
| pause | |
| exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment