I’m using Unity on the Mac at the moment trying to create a game. One of the attractive aspects of Unity is the scripting; I can use C#. Because I’m creating an IOS game I have to use Unity on a Mac. As a result I have to use Mono IDE, which is fine and it works. But despite my best efforts I still hate using a Mac instead of Windows. I’m not a hater, but I hate it.
Rather than spend 10000 hours catching up I just copied the Unity project over to my Windows machine and edited the files in Visual Studio. Bliss.
The problem I then had was how to copy the files back to the Mac so I could complile the game and test it. It had to be a one click process otherwise it’ll be just as fiddly as using the Mac. The two machines are on the same network.
%The Solution%
I created a simple batch file to copy the files to my DropBox but that wasn’t enough. I needed more :
- Prompt me to make sure I really want to copy the scripts over to the Mac
- Create a backup folder in my DropBox. The folder name is date/time based eg; “2012-11-22 22_17_11″. Also create a Mac folder here.
- Copy the scripts I edited on the PC to the new backup folder (version control?)
- Copy the Mac scripts to the 2012-11-22 22_17_11\Mac folder for safekeeping
- Remove all the scripts from the Mac
- Copy the PC scripts over to the Mac
Stuck, I was on the brink of finally having to learn PowerShell when I discovered a fabulous solution (reality). So here it is; a 21st century one-click backup-and-copy solution :
I never knew you could call dynamic javascript from a batch file!
This odd piece of awkward magic performs the following unwieldy tasks :
- creates a tmp.js file which uses familiar javascript to create a variable whose value is the formatted date and time.
- Tmp.js then invokes WScript.Echo to output a dynamic batch file command which sets a batch file variable named YYYYMMDD (not my idea).
- Back in the original batch file tmp.js is executed
- The output (the dynamic batch command) is piped into a temp.bat which is then executed, and you get the formatted date/time filename in the YYYMMDD variable.
It’s like a wormhole that goes from .bat to .js and back again. Insane. I’m sure there’s a more modern solution than this; tell me please!
Wire this up to a button in Visual Studio (reality).
UPDATE
I’ve switched to robocopy now. I use it to mirror the whole unity project from the pc to the mac (but not before a whole heap of project issues sorted themselves out magically). Unity projects are interchangeable between mac and pc and this allows me to do all my development on the pc and switch to the mac when I need to run the game. This is fine for an ios project because at runtime it’s detached from unity anyway so it doesn’t make a lot of difference.
I host a website which remotely sends parameters to the game so I can experiment like you can in the unity ide when running a game from with unity. I debug/log the ios game by using an adapted version of DebugStreamer which outputs text to the screen which can be handy.
I still use the above batch file to backup the script source though I’ll probably switch to bitbucket soon. I can’t really store the whole unity project in bitbucket as it’s 450MB and growing.














Recent Comments