Last active
November 28, 2025 19:32
-
-
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 | |
| :: Define Colors | |
| :DefineColors | |
| for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( | |
| set "ESC=%%b" | |
| ) | |
| 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" | |
| :: 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%" | |
| 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 | |
| if not defined EngineDir ( | |
| if exist "%PluginDir%\..\..\Engine\Build\BatchFiles\RunUAT.bat" set "EngineDir=%PluginDir%\..\..\Engine" | |
| ) | |
| 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 | |
| popd | |
| pause | |
| exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment