lib/u3d/installation.rb in u3d-1.1.5 vs lib/u3d/installation.rb in u3d-1.2.0
- old
+ new
@@ -294,21 +294,38 @@
do_not_move? || !(root_path =~ UNITY_DIR_CHECK_LINUX).nil?
end
end
class WindowsInstallationHelper
- def build_number(exe_path)
- s = string_file_info("Unity Version", exe_path)
+ def initialize(exe_path)
+ @exe_path = exe_path
+ end
+
+ def version
+ s = unity_version_info
if s
a = s.split("_")
+ return a[0] unless a.empty?
+ end
+ nil
+ end
+
+ def build_number
+ s = unity_version_info
+ if s
+ a = s.split("_")
return a[1] if a.count > 1
end
nil
end
private
+ def unity_version_info
+ @uvf ||= string_file_info('Unity Version', @exe_path)
+ end
+
def string_file_info(info, path)
require "Win32API"
get_file_version_info_size = Win32API.new('version.dll', 'GetFileVersionInfoSize', 'PP', 'L')
get_file_version_info = Win32API.new('version.dll', 'GetFileVersionInfo', 'PIIP', 'I')
ver_query_value = Win32API.new('version.dll', 'VerQueryValue', 'PPPP', 'I')
@@ -345,18 +362,21 @@
end
end
class WindowsInstallation < Installation
def version
+ version = helper.version
+ return version unless version.nil?
+
path = "#{root_path}/Editor/Data/"
package = PlaybackEngineUtils.list_module_configs(path).first
raise "Couldn't find a module under #{path}" unless package
PlaybackEngineUtils.unity_version(package)
end
def build_number
- @build_number ||= WindowsInstallationHelper.new.build_number(exe_path)
+ helper.build_number
end
def default_log_file
if @logfile.nil?
begin
@@ -405,8 +425,14 @@
end
end
def clean_install?
do_not_move? || !(root_path =~ UNITY_DIR_CHECK).nil?
+ end
+
+ private
+
+ def helper
+ @helper ||= WindowsInstallationHelper.new(exe_path)
end
end
end