Class: U3d::WindowsInstallation

Inherits:
Installation show all
Defined in:
lib/u3d/installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Installation

create

Constructor Details

#initialize(path: nil) ⇒ WindowsInstallation

Returns a new instance of WindowsInstallation.



121
122
123
# File 'lib/u3d/installer.rb', line 121

def initialize(path: nil)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



119
120
121
# File 'lib/u3d/installer.rb', line 119

def path
  @path
end

Instance Method Details

#default_log_fileObject



135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/u3d/installer.rb', line 135

def default_log_file
  if @logfile.nil?
    begin
      loc_appdata = Utils.windows_local_appdata
      log_dir = File.expand_path('Unity/Editor/', loc_appdata)
      UI.important "Log directory (#{log_dir}) does not exist" unless Dir.exist? log_dir
      @logfile = File.expand_path('Editor.log', log_dir)
    rescue RuntimeError => ex
      UI.error "Unable to retrieve the editor logfile: #{ex}"
    end
  end
  @logfile
end

#exe_pathObject



149
150
151
# File 'lib/u3d/installer.rb', line 149

def exe_path
  File.join(@path, 'Editor', 'Unity.exe')
end

#packagesObject



153
154
155
156
157
158
159
# File 'lib/u3d/installer.rb', line 153

def packages
  # Unity prior to Unity5 did not have package
  return [] if Utils.parse_unity_version(version)[0].to_i <= 4
  fpath = "#{path}/Editor/Data/PlaybackEngines/"
  raise "Unity installation does not seem correct. Couldn't locate PlaybackEngines." unless Dir.exist? fpath
  Dir.entries(fpath).select { |e| File.directory?(File.join(fpath, e)) && !(e == '.' || e == '..') }
end

#versionObject



125
126
127
128
129
130
131
132
133
# File 'lib/u3d/installer.rb', line 125

def version
  require 'rexml/document'
  fpath = "#{path}/Editor/Data/PlaybackEngines/windowsstandalonesupport/ivy.xml"
  raise "Couldn't find file #{fpath}" unless File.exist? fpath
  doc = REXML::Document.new(File.read(fpath))
  version = REXML::XPath.first(doc, 'ivy-module/info/@e:unityVersion').value

  version
end