Class: Fastlane::Helper::UnityHubHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::UnityHubHelper
- Defined in:
- lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb
Class Method Summary collapse
- .parse_installed_editors(installed_editors_string) ⇒ Object
- .unity_binary_relative_to_path(unity_path) ⇒ Object
- .unity_hub_installed_editors ⇒ Object
- .unity_hub_path(escape_for_shell) ⇒ Object
- .verify_default_path ⇒ Object
Class Method Details
.parse_installed_editors(installed_editors_string) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb', line 58 def self.parse_installed_editors(installed_editors_string) installed_editors_list = [] installed_editors_string.split("\n").each do |editor_description| next if editor_description == "" # skipping empty strings # Mac: "2019.4.18f1 , installed at /Applications/Unity/Hub/Editor/2019.4.18f1/Unity.app" # Windows: "2019.4.18f1 , installed at C:\Program Files\Unity\Hub\Editor\2019.4.18f1\Editor\Unity.exe" # Linux: ?? TODO editor_match = editor_description.scan(/((\d+\.\d+\.\d+)[abf]\d+).*installed at (.*)/) installed_editors_list.append( [ editor_match[0][0], # the Unity version editor_match[0][1], # the semantic version part of the Unity version editor_match[0][2] # the path to the Unity Editor ] ) end return installed_editors_list end |
.unity_binary_relative_to_path(unity_path) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb', line 78 def self.unity_binary_relative_to_path(unity_path) # https://docs.unity3d.com/Manual/GettingStartedInstallingHub.html#install if FastlaneCore::Helper.is_mac? # Mac example: "/Applications/Unity/Hub/Editor/<version>/Unity.app" return "#{unity_path}/Contents/MacOS/Unity" elsif FastlaneCore::Helper.is_windows? # Windows example: "C:\Program Files\Unity\Hub\Editor\<version>\Editor\Unity.exe" # path can be taken as is return unity_path elsif FastlaneCore::Helper.linux? # Linux example: ?? TODO UI.error("Not implemented yet") end end |
.unity_hub_installed_editors ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb', line 39 def self.unity_hub_installed_editors UI.("Looking for installed Unity Editors known to the Unity Hub...") # Unity Hub help: "./Unity\ Hub -- --headless help" installed_editors_result = `#{unity_hub_path(true)} -- --headless editors -i` installed_editors_list = parse_installed_editors(installed_editors_result) installed_editors = installed_editors_list.collect do |installed_editor| [installed_editor[0], [ installed_editor[0], installed_editor[1], unity_binary_relative_to_path(installed_editor[2]) ]] end.to_h UI.("Found Unity Editors: #{installed_editors.keys}") return installed_editors end |
.unity_hub_path(escape_for_shell) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb', line 9 def self.unity_hub_path(escape_for_shell) # https://docs.unity3d.com/Manual/GettingStartedInstallingHub.html hub_path = "" if FastlaneCore::Helper.is_mac? hub_path = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" elsif FastlaneCore::Helper.is_windows? hub_path = "C:\\Program Files\\Unity Hub\\Unity Hub.exe" elsif FastlaneCore::Helper.linux? # TODO UI.error("Not implemented yet") end if escape_for_shell return Helper::GenericHelper.shellify(hub_path) else return hub_path end end |
.verify_default_path ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb', line 29 def self.verify_default_path # verifies that the Unity Hub exists at the default path exists = File.file?(Helper::UnityHubHelper.unity_hub_path(false)) unless exists UI.error("Unity Hub does not exist at path '#{Helper::UnityHubHelper.unity_hub_path(false)}'") end return exists end |