Class: U3d::UnityProject

Inherits:
Object
  • Object
show all
Defined in:
lib/u3d/unity_project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ UnityProject

Returns a new instance of UnityProject.



31
32
33
# File 'lib/u3d/unity_project.rb', line 31

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



29
30
31
# File 'lib/u3d/unity_project.rb', line 29

def path
  @path
end

Instance Method Details

#assets_pathObject



39
40
41
# File 'lib/u3d/unity_project.rb', line 39

def assets_path
  File.join(@path, 'Assets')
end

#editor_versionObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/u3d/unity_project.rb', line 47

def editor_version
  require 'yaml'
  project_version = File.join(project_settings_path, 'ProjectVersion.txt')
  return nil unless File.exist? project_version

  yaml = YAML.safe_load(File.read(project_version))
  version = yaml['m_EditorVersion']
  version = version.gsub(/(\d+\.\d+\.\d+)(?:x)?(\w\d+)(?:Linux)?/, '\1\2') if Helper.linux?
  version
end

#exist?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/u3d/unity_project.rb', line 35

def exist?
  Dir.exist?(assets_path) && Dir.exist?(project_settings_path)
end

#project_settings_pathObject



43
44
45
# File 'lib/u3d/unity_project.rb', line 43

def project_settings_path
  File.join(@path, 'ProjectSettings')
end