Last active
April 20, 2023 16:16
-
-
Save Solessfir/8ed3df75b51214661131bc13dc9d05ee to your computer and use it in GitHub Desktop.
Unreal Engine Derived Data Cache 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 used for building a "Derived Data Cache" for an Unreal Engine project. | |
:: A "Derived Data Cache" is a database of preprocessed assets that are used to speed up the development process in Unreal Engine. | |
:: The batch file searches for a .uproject file in the current directory and its parent directory. | |
:: Once found, it extracts the EngineAssociation parameter from the .uproject file to determine the version of the Unreal Engine used to create the project. | |
:: Then it searches the Windows registry for the installation directory of that version of Unreal Engine. | |
:: Once the installation directory is found, the batch file calls the Unreal Editor with the necessary parameters to build the "Derived Data Cache". | |
:: To use this batch file, simply place it in the directory containing your Unreal Engine project, and double-click on it to run it. | |
:: If successful, the batch file will build the "Derived Data Cache" for your project. | |
:: If there are any errors during the process, the batch file will display an error message and pause before exiting. | |
@echo off | |
setlocal EnableDelayedExpansion | |
title Build Derived Data Cache | |
set RootDirectory=%~dp0 | |
set RootDirectory=%RootDirectory:~0,-1% | |
for %%i in ("%RootDirectory%\*.uproject") do ( | |
set UprojectFilePath=%%~i | |
goto UprojectLocationFound | |
) | |
cd.. | |
set RootDirectory=%cd% | |
for %%i in ("%RootDirectory%\*.uproject") do ( | |
set UprojectFilePath=%%~i | |
goto UprojectLocationFound | |
) | |
echo [91mError: No .uproject file found in %RootDirectory%[0m | |
goto ExitWithPause | |
:UprojectLocationFound | |
for /f "tokens=2 delims=: " %%a in ('findstr /i /c:"EngineAssociation" "%UprojectFilePath%"') do ( | |
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 %UprojectFilePath%[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 ( | |
if "%EngineVersion:~0,1%"=="4" ( | |
set UnrealEditor=UE4Editor.exe | |
) else ( | |
set UnrealEditor=UnrealEditor.exe | |
) | |
set UnrealEditorPath=!EngineDirectory!\Engine\Binaries\Win64\!UnrealEditor! | |
echo Unreal Editor Path: !UnrealEditorPath! | |
call "!UnrealEditorPath!" "!UprojectFilePath!" -run=DerivedDataCache -fill -DDC=CreatePak -ProjectOnly | |
) 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