Skip to content

Instantly share code, notes, and snippets.

@Solessfir
Last active February 16, 2026 13:36
Show Gist options
  • Select an option

  • Save Solessfir/9e8a89a581e321649dfdc5027bcdaaad to your computer and use it in GitHub Desktop.

Select an option

Save Solessfir/9e8a89a581e321649dfdc5027bcdaaad to your computer and use it in GitHub Desktop.
Unreal Engine Standalone Plugin Builder
:: 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_Red!Error: 'EngineVersion' not found in .uplugin file.!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. 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!
echo:
set "OutputDir=%PluginDir%\Build"
:: Clean previous build
if exist "%OutputDir%" (
echo Cleaning previous build...
rd /s /q "%OutputDir%" >nul 2>&1
)
:: Execute RunUAT
call "!RunUAT!" BuildPlugin -Plugin="%UpluginFile%" -Package="%OutputDir%" -Rocket -TargetPlatforms=%TargetPlatform%
echo:
if !errorlevel! 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