Skip to content

Instantly share code, notes, and snippets.

@tmr111116
Last active April 16, 2017 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmr111116/ba08bcdbcb615bd83c81 to your computer and use it in GitHub Desktop.
Save tmr111116/ba08bcdbcb615bd83c81 to your computer and use it in GitHub Desktop.
ProjectVersion によって起動する Unity を変えるやつコマンドライン引数対応版。
#!/usr/bin/env ruby
require "yaml"
UNITY_DIR_PREFIX = ENV.fetch("UNITY_DIR_PREFIX", "/Applications/Unity")
unity_args = ARGV.dup
project_path = Dir.getwd
path_arg = ARGV.index("-projectPath")
if path_arg
project_path = ARGV[path_arg + 1]
else
unity_args.unshift("-projectPath", project_path)
end
project_settings = File.join(project_path, "ProjectSettings")
raise "#{project_path} は Unity プロジェクトじゃない!" unless Dir.exists?(project_settings)
version_file = File.join(project_settings, "ProjectVersion.txt")
def get_project_version(version_file)
# ProjectVersion.txt がなかったら 4 系として扱う。
return "4" unless File.exists?(version_file)
yaml = YAML.load_file(version_file)
yaml["m_EditorVersion"]
end
version = get_project_version(version_file)
unity_dir = UNITY_DIR_PREFIX + version
raise "Version #{version} の Unity が #{unity_dir} にインストールされていない!" unless Dir.exists?(unity_dir)
exe_path = File.join(unity_dir, "Unity.app", "Contents", "MacOS", "Unity")
puts "exec '#{exe_path}' #{unity_args}"
exit(system(exe_path, *unity_args))
@tmr111116
Copy link
Author

github に移した。 https://github.com/tmr111116/urun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment