Skip to content

Instantly share code, notes, and snippets.

@kyubuns
Last active October 26, 2015 07:34
Show Gist options
  • Save kyubuns/d305a7fc78cade66fd87 to your computer and use it in GitHub Desktop.
Save kyubuns/d305a7fc78cade66fd87 to your computer and use it in GitHub Desktop.
Mac用。適切っぽいバージョンのUnityでプロジェクトを開く。 ex. open_unity ~/code/unity_project/
Target=$(cd $(dirname $1) && pwd)/$(basename $1)
if [ $# == 0 ]; then
echo "Usage: OpenUnity [project path] [unity version]"
exit 0
fi
if [ ! -e "${Target}/ProjectSettings/ProjectVersion.txt" ]; then
echo "${Target}/ProjectSettings/ProjectVersion.txt が見つかりません。"
exit 1
fi
UnityVersion=`head -n 1 ${Target}/ProjectSettings/ProjectVersion.txt | cut -d " " -f 2-2`
if [ $# == 2 ]; then
UnityVersion=$2
fi
# Unityを探す
for i in `seq ${#UnityVersion} 0`; do
SearchVersion=`echo "/Applications/Unity${UnityVersion:0:i}*"`
SearchVersion=`echo ${SearchVersion} | cut -d ' ' -f 1`
if [ -e $SearchVersion ]; then
if [ ! $i == ${#UnityVersion} ]; then
echo "Unity${UnityVersion}が見つかりません。"
echo "`basename ${SearchVersion}`で開きますか? [y/N]"
read Reply
if [[ ! $Reply =~ ^[Yy]$ ]]; then
exit 1
fi
fi
echo "`basename ${SearchVersion}`でプロジェクトを開きます。"
$SearchVersion/Unity.app/Contents/MacOS/Unity -projectPath ${Target}&
exit 0
fi
done
echo "Unity not found"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment