Class: Pindo::TaskSystem::UnityExportTask

Inherits:
UnityTask show all
Defined in:
lib/pindo/module/task/model/unity/unity_export_task.rb

Overview

Unity 导出任务用于将 Unity 项目导出为指定平台(iOS/Android/WebGL)

Instance Attribute Summary collapse

Attributes inherited from UnityTask

#project_path, #unity_root_path

Attributes inherited from PindoTask

#callbacks_setup, #context, #created_at, #data_dependencies, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #started_at, #status, #task_key, #task_manager, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UnityTask

#before_retry, default_retry_count, default_retry_delay, default_retry_mode, task_type, task_type_name, #unity_helper

Methods inherited from PindoTask

#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, default_retry_count, default_retry_delay, default_retry_mode, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #reset_for_retry, #retryable?, #running?, #should_retry?, task_type

Constructor Details

#initialize(platform, options = {}) ⇒ UnityExportTask

Returns a new instance of UnityExportTask.

Parameters:

  • platform (String)

    目标平台 (‘ios’, ‘android’, ‘web’)

  • options (Hash) (defaults to: {})

    额外选项

    • :project_path [String] Unity 项目路径(默认当前目录)

    • :export_path [String] 导出路径(nil 表示自动检测)

    • :deploy_mode [String] 部署模式 (‘dev’, ‘adhoc’, ‘release’),默认 ‘dev’

    • :context [Hash] 上下文信息(如 index_count)



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 22

def initialize(platform, options = {})
  @platform = platform
  @unity_exe_path = nil  # 将在 do_work 中自动查找
  @is_library_mode = false
  @index_count = options[:context] ? options[:context][:index_count] : nil
  @export_path = options[:export_path]  # 可由参数传入,nil 表示自动检测
  @deploy_mode = options[:deploy_mode] || 'dev'  # 部署模式:dev/adhoc/release,默认 dev

  name = case platform
         when 'ios', 'ipa'
           "Unity导出iOS平台"
         when 'android', 'apk'
           "Unity导出Android平台"
         when 'web', 'html'
           "Unity导出WebGL平台"
         else
           "Unity导出#{platform.upcase}平台"
         end

  # 传递 project_path 给基类
  options[:project_path] ||= Dir.pwd
  super(name, options)
end

Instance Attribute Details

#deploy_modeObject (readonly)

Returns the value of attribute deploy_mode.



9
10
11
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 9

def deploy_mode
  @deploy_mode
end

#export_pathObject (readonly)

Returns the value of attribute export_path.



9
10
11
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 9

def export_path
  @export_path
end

#is_library_modeObject (readonly)

Returns the value of attribute is_library_mode.



9
10
11
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 9

def is_library_mode
  @is_library_mode
end

#platformObject (readonly)

Returns the value of attribute platform.



9
10
11
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 9

def platform
  @platform
end

Class Method Details

.task_keyObject

任务键



12
13
14
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 12

def self.task_key
  :unity_export
end

Instance Method Details

#validateObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/pindo/module/task/model/unity/unity_export_task.rb', line 46

def validate
  super

  # 验证 Unity 工程是否存在
  unless unity_helper.unity_project?(@unity_root_path)
    raise Informative, "当前目录不是 Unity 工程:#{@unity_root_path}"
  end

  true
end