Skip to content

Instantly share code, notes, and snippets.

@Knetic
Last active July 10, 2018 11:11
Show Gist options
  • Save Knetic/142ca671fca93d1c325c77987ce3ab19 to your computer and use it in GitHub Desktop.
Save Knetic/142ca671fca93d1c325c77987ce3ab19 to your computer and use it in GitHub Desktop.
Recompiles and hot-reloads the game module for a ue4 project from commandline
#!/bin/bash
# No arguments - run in the same directory as your "*.uproject" file.
UNR_PATH="<PATH_TO_YOUR_UNREALENGINE>/UnrealEngine"
RANDNUM=$(( ( RANDOM % 1000 ) + 1000 ))
CURR_DIR=$(pwd)
PROJECT_PATH=$(find ${CURR_DIR} -maxdepth 1 -name "*.uproject")
PROJECT_FILE=$(basename ${PROJECT_PATH})
PROJECT_NAME=${PROJECT_FILE%.*}
${UNR_PATH}/Engine/Build/BatchFiles/Linux/RunMono.sh \
${UNR_PATH}/Engine/Binaries/DotNET/UnrealBuildTool.exe \
"$PROJECT_NAME" \
-ModuleWithSuffix \
"${PROJECT_NAME}" \
${RANDNUM} \
Linux \
Development \
-editorrecompile \
-canskiplink \
"$PROJECT_PATH" \
-progress
# Note that UE >4.18 seems to break the ${RANDNUM} strategy - the syntax seems to have changed to "-Module=<name>,<suffix>, but this seems to fail with the RANDNUM strategy
@shareeff
Copy link

This one works for me. I have added the following function in my bashrc file.
function unrealbuild4.19 {
UNR_PATH=opt/UnrealEngine4.19.1/UnrealEngine;
RANDNUM=$(( ( RANDOM % 1000 ) + 1000 ));
CURR_DIR=pwd;
PROJ_NAME=$(basename ${1%.uproject});
${UNR_PATH}/Engine/Build/BatchFiles/Linux/Build.sh $PROJ_NAME -ModuleWithSuffix=$PROJ_NAME,$RANDNUM Linux Development -editorrecompile -canskiplink "${CURR_DIR}/${PROJ_NAME}.uproject" -progress
}

Most probably you need to modify this line -ModuleWithSuffix ${PROJECT_NAME} ${RANDNUM} in your code.
I have got the reference from here
https://github.com/EpicGames/UnrealEngine/blob/08ee319f80ef47dbf0988e14b546b65214838ec4/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildTarget.cs#L443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment