Class: Fastlane::Helper::UnityHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/unity/helper/unity_helper.rb

Class Method Summary collapse

Class Method Details

.find_unity_path(unity_version) ⇒ Object

class methods that you define here become available in your action as Helper::UnityHelper.your_method



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/unity/helper/unity_helper.rb', line 13

def self.find_unity_path(unity_version)
  paths = []

  if OS::Underlying.docker?
    # Unity docker image
    # https://gitlab.com/gableroux/unity3d
    paths << '/opt/Unity/Editor/Unity'
  end

  if OS.windows?
    # Unity Hub
    paths << "C:\\Program Files\\Unity\\Hub\\Editor\\#{unity_version}\\Editor\\Unity.exe" if unity_version
    # Without Unity Hub
    paths << 'C:\\Program Files\\Unity\\Editor\\Unity.exe'
  elsif OS.mac?
    # Unity Hub
    paths << "/Applications/Unity/Hub/Editor/#{unity_version}/Unity.app/Contents/MacOS/Unity" if unity_version
    # install-unity
    # https://github.com/sttz/install-unity
    paths << "/Applications/Unity #{unity_version}/Unity.app/Contents/MacOS/Unity" if unity_version
    # Without Unity Hub
    paths << '/Applications/Unity/Unity.app/Contents/MacOS/Unity'
  elsif OS.linux?
    # Unity Hub
    paths << "~/Unity/Hub/Editor/#{unity_version}/Editor/Unity" if unity_version
  end

  paths.find { |path| File.exist?(path) }
end