I couldn’t get hot reloading to work on 4.20. Previous answers had used a ModuleWithSuffix
argument to add a random number to the end. Instead, this script builds normally using cmake (from a CLion project) and then copies the resulting libraries and appends a new random number. Unreal seems to hot reload based on the presence of a libUE4Editor-PROJECT_NAME-XXXX
based library string…if anyone reading is having trouble with a different version and this script doesn’t work, it may give you a hint.
#!/bin/bash
# Used with Unreal version 4.20
UNREAL_PATH=${HOME}/Developer/UnrealEngine;
RANDNUM=$(( ( RANDOM % 1000 ) + 1000 ));
CURR_DIR=`pwd`;
UPROJECT_FILE="$1";
UPROJECT_PATH=$(dirname "${UPROJECT_FILE}");
PROJ_NAME="$(basename "${UPROJECT_FILE%.uproject}")";
PROJ_NAME_EDITOR="${PROJ_NAME}Editor"
OUTPUT_BASE_NAME="libUE4Editor-"
N_CPUS=$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}')
# make using cmake
cmake --build "${UPROJECT_PATH}/cmake-build-debug" --target "${PROJ_NAME_EDITOR}" -- -j ${N_CPUS}
# copy the created files to have the random number appended, this will trigger a hot reload
if [ $? -eq 0 ]; then
BINARY_BASENAME="${UPROJECT_PATH}/Binaries/Linux/${OUTPUT_BASE_NAME}${PROJ_NAME}"
cp "${BINARY_BASENAME}.debug" "${BINARY_BASENAME}-${RANDNUM}.debug"
cp "${BINARY_BASENAME}.so" "${BINARY_BASENAME}-${RANDNUM}.so"
cp "${BINARY_BASENAME}.sym" "${BINARY_BASENAME}-${RANDNUM}.sym"
echo "Successfully hot reloaded"
fi