Last active
April 3, 2023 18:01
-
-
Save elibroftw/be1f6ad737ccde25e86f858f2f11629f to your computer and use it in GitHub Desktop.
A Python script to build Unity projects without the editor open.
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
import subprocess | |
import shutil | |
import os | |
import zipfile | |
import threading | |
print('Cleaning up build directory') | |
shutil.rmtree('Builds', ignore_errors=True) | |
print('Starting build process') | |
UNITY = '"C:\\Program Files\\Unity\\Hub\\Editor\\2019.3.14f1\\Editor\\Unity.exe"' | |
subprocess.run( | |
f'{UNITY} -quit -projectPath -batchmode {os.getcwd()} -executeMethod BuildScript.BuildAll') | |
print('Build process ended') | |
def zipdir(path): | |
ziph = zipfile.ZipFile(f'{os.path.basename(path)}.zip', 'w', zipfile.ZIP_DEFLATED) | |
for root, dirs, files in os.walk(path): | |
for file in files: | |
ziph.write(os.path.join(root, file)) | |
print('Zipping Builds') | |
zipdir('Builds/Windows') | |
zipdir('Builds/Linux') | |
zipdir('Builds/Web GL') | |
zipdir('Builds/MacOSX.app') | |
print('Zipping Complete') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment