MacにUnityのキャッシュサーバーを導入してみる
概要
ビルド時間、Switchプラットフォーム高速化のため Unityのキャッシュサーバーを導入してLaunchAgent登録するところまでやってみました。
インストール
バージョン6以上からはGithubでの管理になりました。
Readme通りnpmでインストールできます。
npm install unity-cache-server -g
npm入れてない場合はあらかじめインストールしましょう。
起動スクリプト作成
com.unity3d.CacheServer.sh
#!/bin/sh export PATH=/usr/local/bin:$PATH PORT=8126 /usr/local/bin/unity-cache-server --port ${PORT} --log-level 5
権限設定を忘れずに行いましょう。
chmod 744 com.unity3d.CacheServer.sh
port 8126はデフォルトです。
LaunchAgentへ登録
こちらの~/Library/LaunchAgents/com.unity3d.CacheServer.plist
にplistを作成します。
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.unity3d.CacheServer</string> <key>ProgramArguments</key> <array> <string>(先ほど作ったディレクトリ)/com.unity3d.CacheServer.sh</string> </array> <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict> <key>RunAtLoad</key> <true/> <key>StandardOutPath</key> <string>/tmp/com.unity3d.CacheServer.out</string> <key>StandardErrorPath</key> <string>/tmp/com.unity3d.CacheServer.err</string> </dict> </plist>
登録方法はこちらです。
launchctl load ~/Library/LaunchAgents/com.unity3d.CacheServer.plist
解除はこちらです。
launchctl unload ~/Library/LaunchAgents/com.unity3d.CacheServer.plist
UnityのPreference登録
ローカルだけではなくリモートの登録も可能です。 チーム開発している場合などは、便利かもしれません。