強火で進め

このブログではプログラム関連の記事を中心に書いてます。

Mac版のUnityで複数のプロジェクトを同時に開く方法

Mac版のUnityではPreferences(ショートカットは command+, )の「Always Show Project Wizard」にチェックを入れ、

ターミナルで以下のコマンドを実行すると複数起動が可能です。

open -n /Applications/Unity/Unity.app

※起動時にoption(alt)キーを押しっぱなしすれば「Always Show Project Wizard」のチェックは必要無し。

しかし、この方法では毎回起動時にプロジェクトを選択しなといけないのでちょっとだけ面倒くさいと思っていました。

そんな思いを解決してくれる方法がこちらのブログに書かれていました。そう言えばUnityはコマンドラインからの起動時には開くプロジェクトを指定出来るのでした(すっかり忘れてましたw)。

Opening Multiple Unity3D Instances
http://computer-programming-languages.knoji.com/opening-multiple-unity3d-instances/

Unity - Command line arguments
http://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html

という事でこの起動方法を簡単に実行出来る様にAutomatorでアプリを作る事にしました。
こちらからダウンロードして使って下さい。

開きたいUnityのプロジェクトをこのアプリにドラッグするとUnityが新規に起動します。

ソースコード

ソースコードも貼っておきます。「AppleScript を実行」を追加して以下のプログラムを記入すれば同様のアプリを作成出来ます。

on run {input, parameters}
	set listSize to count of input
	if listSize = 0 then
		display alert "Unityのプロジェクトをドラッグして下さい"
	else
		set posixDirPath to item 1 of input
		set dirPath to POSIX path of posixDirPath
		--display alert dirPath
		do shell script "/Applications/Unity/Unity.app/Contents/MacOS/Unity -projectPath \"" & dirPath & "\" &> /dev/null &"
	end if
	return input
end run

参考にした情報

AppleScriptでファイルのパスを旧Mac形式からPOSIX形式に変換する情報

Travellers Tale: POSIX 形式の path と Mac 従来の path の変換
http://mac.travel-lab.info/travellers/blog/C746134881/E613669364/

AppleScript and POSIX paths
http://www.satimage.fr/software/en/smile/external_codes/file_paths.html