Skip to content

Instantly share code, notes, and snippets.

@Solessfir
Last active April 20, 2023 16:12
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 is a batch file that is used to build a plugin for the Unreal Engine.
:: The file first sets the root directory to the current directory of the batch file.
:: It searches for a ".uplugin" file in the root directory and its parent directory.
:: If it doesn't find any ".uplugin" files, it outputs an error message and exits the script.
:: If it finds a ".uplugin" file, it extracts the engine version from the file and looks for the Unreal Engine installation directory in the Windows registry.
:: If it finds the installation directory, it sets the path to the AutomationTool, which is used to build the plugin.
:: If it can't find the installation directory, it outputs an error message and exits the script.
:: Finally, the script calls the AutomationTool with the appropriate parameters to build the plugin, including the path
:: to the ".uplugin" file, the target platform (in this case, Win64), and the output directory.
:: Once the build is complete, the script prompts the user to press any key to exit.
:: To use this batch file, you need to save it in the root directory of your plugin project and double-click it to run.
:: Make sure you have the Unreal Engine installed on your system and that the version number matches the one specified in the ".uplugin" file.
:: Also, ensure that the necessary build tools are installed for the target platform you want to build the plugin for.
@echo off
setlocal EnableDelayedExpansion
title Build Plugin
set RootDirectory=%~dp0
set RootDirectory=%RootDirectory:~0,-1%
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%
goto ExitWithPause
:UpluginLocationFound
for /f "tokens=2 delims=: " %%a in ('findstr /i /c:"EngineAssociation" /c:"EngineVersion" "%UpluginFilePath%"') do (
if %%a=="EngineAssociation" (
set EngineVersion=%%a
set EngineVersion=!EngineVersion:~1,-2!
) else (
set EngineVersion=%%a
set EngineVersion=!EngineVersion:~1,-2!
)
)
for /f "tokens=1-3 delims=." %%a in ("%EngineVersion%") do (
set EngineVersion=%%a.%%b
)
if not defined EngineVersion (
echo Error: No Engine association found in %UpluginFilePath%
goto ExitWithPause
)
for /f "skip=2 tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%EngineVersion%" /v "InstalledDirectory"') do (
set EngineDirectory=%%b
)
if defined EngineDirectory (
set AutomationToolPath=!EngineDirectory!\Engine\Build\BatchFiles\RunUAT.bat
echo Automation Tool Path: !AutomationToolPath!
echo:
call "!AutomationToolPath!" BuildPlugin -Plugin="!UpluginFilePath!" -Package="!RootDirectory!\Build" -Rocket -TargetPlatforms=Win64
) else (
echo Error: Couldn't find Unreal Engine installation location!
goto ExitWithPause
)
:ExitWithPause
pause
exit /b 0
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment