Class: Mikunyan::AssetBundle

Inherits:
Object
  • Object
show all
Defined in:
lib/mikunyan/asset_bundle.rb

Overview

Class for representing Unity AssetBundle

Defined Under Namespace

Classes: AssetEntry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetsArray<Mikunyan::Asset> (readonly)

contained Assets

Returns:



16
17
18
# File 'lib/mikunyan/asset_bundle.rb', line 16

def assets
  @assets
end

#blobsObject (readonly)

Returns the value of attribute blobs.



17
18
19
# File 'lib/mikunyan/asset_bundle.rb', line 17

def blobs
  @blobs
end

#formatInteger (readonly)

file format number

Returns:

  • (Integer)

    the current value of format



16
17
18
# File 'lib/mikunyan/asset_bundle.rb', line 16

def format
  @format
end

#generator_versionString (readonly)

version string of generator

Returns:

  • (String)

    the current value of generator_version



16
17
18
# File 'lib/mikunyan/asset_bundle.rb', line 16

def generator_version
  @generator_version
end

#guidString (readonly)

unique identifier (can be zero)

Returns:

  • (String)

    the current value of guid



16
17
18
# File 'lib/mikunyan/asset_bundle.rb', line 16

def guid
  @guid
end

#signatureString (readonly)

file signature (UnityRaw or UnityFS)

Returns:

  • (String)

    the current value of signature



16
17
18
# File 'lib/mikunyan/asset_bundle.rb', line 16

def signature
  @signature
end

#unity_versionString (readonly)

version string of Unity for this AssetBundle

Returns:

  • (String)

    the current value of unity_version



16
17
18
# File 'lib/mikunyan/asset_bundle.rb', line 16

def unity_version
  @unity_version
end

Class Method Details

.file(file) ⇒ Mikunyan::AssetBundle

Loads AssetBundle from file

Parameters:

  • file (String)

    file name

Returns:



45
46
47
48
49
# File 'lib/mikunyan/asset_bundle.rb', line 45

def self.file(file)
  File.open(file, 'rb') do |io|
    AssetBundle.load(io)
  end
end

.load(bin) ⇒ Mikunyan::AssetBundle

Loads AssetBundle from binary string

Parameters:

  • bin (String, IO)

    binary data

Returns:



36
37
38
39
40
# File 'lib/mikunyan/asset_bundle.rb', line 36

def self.load(bin)
  r = AssetBundle.new
  r.send(:load, bin)
  r
end

Instance Method Details

#[](index) ⇒ Mikunyan::Asset?

Parameters:

  • index (String, Integer)

Returns:



23
24
25
# File 'lib/mikunyan/asset_bundle.rb', line 23

def [](index)
  index.is_a?(String) ? @assets.find {|e| e.name == index} : @assets[index]
end

#each_asset(&block) ⇒ Enumerator<Mikunyan::Asset>, Array<Mikunyan::Asset>

Same as assets.each

Returns:



29
30
31
# File 'lib/mikunyan/asset_bundle.rb', line 29

def each_asset(&block)
  @assets.each(&block)
end