Skip to content

Instantly share code, notes, and snippets.

@Solessfir
Last active June 11, 2025 07:06
Show Gist options
  • Save Solessfir/9e8a89a581e321649dfdc5027bcdaaad to your computer and use it in GitHub Desktop.
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 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 Error: No .uplugin file found in %RootDirectory% or its parent directory.
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 Error: EngineVersion is missing in %UpluginFilePath%. Cannot build the plugin.
goto :ExitWithPause
)
if "!EngineVersion!"=="" (
echo Error: EngineVersion is empty in %UpluginFilePath%. Cannot build the plugin.
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 Error: Couldn't find Unreal Engine installation for version !EngineVersion!.
echo Ensure Unreal Engine !EngineVersion! is installed via the Epic Games Launcher.
goto :ExitWithPause
)
:: Set path to AutomationTool
set "AutomationToolPath=!EngineDirectory!\Engine\Build\BatchFiles\RunUAT.bat"
if not exist "!AutomationToolPath!" (
echo Error: AutomationTool not found at !AutomationToolPath!.
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 Error: Plugin build failed. Check the AutomationTool log for details.
) else (
echo Plugin build completed successfully. Output in %RootDirectory%\Build
)
:ExitWithPause
pause
exit /b 0
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment