Last active
April 20, 2023 16:12
-
-
Save Solessfir/9e8a89a581e321649dfdc5027bcdaaad to your computer and use it in GitHub Desktop.
Unreal Engine Standalone Plugin Builder
This file contains 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 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 [91mError: No .uplugin file found in %RootDirectory%[0m | |
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 [91mError: No Engine association found in %UpluginFilePath%[0m | |
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 [91mError: Couldn't find Unreal Engine installation location![0m | |
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