kill existing unity processes before attempting build

This commit is contained in:
Cat Flynn 2021-01-30 14:16:26 +00:00
parent d28a2b22c5
commit 6290dde9db
1 changed files with 47 additions and 40 deletions

View File

@ -3,10 +3,18 @@
# $1 UNITY_VERSION # $1 UNITY_VERSION
unityversion=$1 unityversion=$1
editorlogpath="$HOME/Library/Logs/Unity/Editor.log"
editorpath="/Applications/Unity/Hub/Editor/$unityversion/Unity.app" editorpath="/Applications/Unity/Hub/Editor/$unityversion/Unity.app"
# find and kill existing unity instances
if pgrep -x Unity
then
echo "terminating existing unity processes..."
kill $(pgrep Unity)
fi
# remove previous Editor.log # remove previous Editor.log
editorlogpath="$HOME/Library/Logs/Unity/Editor.log" echo "removing previous editor log..."
[ -f $editorlogpath ] && rm $editorlogpath [ -f $editorlogpath ] && rm $editorlogpath
echo "starting build using unity v$unityversion..." echo "starting build using unity v$unityversion..."
@ -21,12 +29,11 @@ open -g $editorpath --args \
-projectPath "$(pwd)/game" -projectPath "$(pwd)/game"
# wait for unity to exit # wait for unity to exit
while pgrep -x "Unity" > /dev/null while pgrep -x Unity > /dev/null
do do
sleep 1 sleep 1
done done
if [ -f $editorlogpath ]; then if [ -f $editorlogpath ]; then
echo "build completed, dumping log" echo "build completed, dumping log"
cat $editorlogpath cat $editorlogpath