I finally cleaned up one of my personal scripts, and I think it’s ready for public usage. It’s the handiest script I’ve ever made, to be honest.
This script does two things:
1) It will build your last opened Unity project to Windows, Mac, and Linux.
2) It will neatly zip up each build.
Yes, it’s pretty simple, but very useful. Unfortunately this script is Mac-only for now. Perhaps in the near future I will write a batch file for Windows. You could also do it yourself and share it to me! I’m sure many people would love it.
If you’re unsure how to use this, you must make sure of a few things. You must have Unity installed. You must be on a Mac.
- Open your project in Unity.
- Close Unity.
- Download the script file.
- Make sure the script file is named “UnityBuildAll.sh“
- Since downloading a script doesn’t make it executable, you can do one of two things. You can make it executable, or just run it with the shell command. We will do the latter. See Additional Notes below if you want to make it executable.
- Open Terminal. (/Applications/Utilities/Terminal)
- Navigate to the folder where you downloaded the script file. You can do “cd ~/Downloads” to go to your Downloads folder.
- Then, run this command (the $ sign you do not type.)
$ sh UnityBuildAll.sh app_name target_folder readme_file
Replace “app_name” with your game’s name.
target_folder and readme_file are optional arguments.
Replace “target_folder” with where you want the builds to go. By default, they will go to ~/UnityBuilds/appname/ (That’s in your user folder.)
Replace “readme_file” with any readme file you want to include in the zip.
9. Wait until you see the command prompt again, and then you’re done!
If you want to keep using the script file easily, I recommend “installing” it.
- Go to the directory the script file is in using the Terminal. (If it’s in your downloads folder, do “cd ~/Downloads“
- Make the script file executable by running:
$ chmod +x UnityBuildAll.sh
3. Rename the script to not have .sh at the end.
$ mv UnityBuildAll.sh UnityBuildAll
4. Copy the script to your bin folder (essentially where Terminal programs are stored.) You will need admin rights.
$ sudo cp UnityBuildAll /usr/bin/UnityBuildAll
And that’s about it! Now, you can just run this script wherever you want. That means, to build your game, all you have to do is close Unity, open the Terminal, and run, for example:
$ UnityBuildAll Zarvot ~/ZarvotBuilds