Skip to content

Instantly share code, notes, and snippets.

@tayl0r
Created July 31, 2014 15:32
Show Gist options
  • Save tayl0r/8fa8b1df5b218d406e0a to your computer and use it in GitHub Desktop.
Save tayl0r/8fa8b1df5b218d406e0a to your computer and use it in GitHub Desktop.
command line Unity startup of specific project
perl startUnity.pl
use strict;
# figure out project path
use Cwd 'abs_path';
my $cwd = abs_path($0);
$cwd =~ s/$0//g;
my $projPath;
if ($^O eq "MSWin32") {
$projPath = $cwd . '..\UnityProject\JackpotSlots';
} else {
$projPath = $cwd . '../UnityProject/JackpotSlots';
}
# figure out unity path
my @unityPaths = ('c:\Program Files (x86)\Unity\Editor\Unity.exe', '/Applications/Unity4.5/Unity.app/Contents/MacOS/Unity', '/Applications/Unity/Unity.app/Contents/MacOS/Unity');
my $unityPath;
foreach my $dir (@unityPaths) {
if (-d $dir || -e $dir) {
$unityPath = $dir;
}
}
print "$unityPath\n";
print "$projPath\n";
my $cmd = qq|"$unityPath" -projectPath "$projPath"|;
use threads;
my $thr = threads->create(sub { system($_[0]); }, $cmd);
$thr->detach();
sleep 2;
perl startUnity.pl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment