Last active
January 6, 2017 03:55
-
-
Save Knetic/0ed46af56d38347cc8d4af7f7857add3 to your computer and use it in GitHub Desktop.
fixed copy/paste error
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
#!/usr/bin/env python | |
# Invokes a build of this project's assets as a unitypackage. | |
# Working directory must be in the top-level of the project, i.e., "Assets" must be directly underneath cwd. | |
import sys | |
import os | |
import subprocess | |
from distutils.spawn import find_executable | |
# Determines a Unity editor executable that is available from the PATH. | |
# If none can be found, returns None. | |
def determineUnityExecutable(): | |
possibleExecutables = ["Unity", "unityEditor"] | |
for executable in possibleExecutables: | |
actualExecutable = find_executable(executable) | |
if(actualExecutable != None): | |
return actualExecutable | |
return None | |
def main(): | |
workingDirectory = os.getcwd() | |
baseDirectory = os.path.basename(os.path.normpath(workingDirectory)) | |
executable = determineUnityExecutable() | |
if(executable == None): | |
print("Unable to find unity executable, make sure either 'Unity' or 'unityEditor' are available within your path.") | |
sys.exit(1) | |
# Shellout. | |
arguments = [ | |
executable, | |
"-batchmode", | |
"-nographics", | |
"-quit", | |
"-projectPath", | |
workingDirectory, | |
"-exportPackage", | |
"Assets", | |
baseDirectory + ".unityPackage" | |
] | |
friendlyArguments = ' '.join(arguments) | |
print("Calling Unity: [" + friendlyArguments + "]") | |
statusCode = subprocess.call(arguments, shell=False, stdout=sys.stdout, stderr=sys.stderr) | |
if(statusCode != 0): | |
print("Call to unity failed with status code " + str(statusCode)) | |
return statusCode | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment