format codes
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
require "bundler/gem_tasks"
|
# frozen_string_literal: true
|
||||||
require "rake/extensiontask"
|
|
||||||
|
require 'bundler/gem_tasks'
|
||||||
|
require 'rake/extensiontask'
|
||||||
|
|
||||||
task :scream do
|
task :scream do
|
||||||
puts "みくは自分を曲げないよ!"
|
puts 'みくは自分を曲げないよ!'
|
||||||
end
|
end
|
||||||
|
|
||||||
task :build => :compile
|
task build: :compile
|
||||||
|
|
||||||
Rake::ExtensionTask.new('decoders/native') do |ext|
|
Rake::ExtensionTask.new('decoders/native') do |ext|
|
||||||
ext.lib_dir = 'lib/mikunyan'
|
ext.lib_dir = 'lib/mikunyan'
|
||||||
end
|
end
|
||||||
|
|
||||||
task :default => [:clobber, :compile, :spec]
|
task default: %i[clobber compile spec]
|
||||||
|
|||||||
+9
-7
@@ -1,11 +1,13 @@
|
|||||||
require "mikunyan/version"
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "mikunyan/asset_bundle"
|
require 'mikunyan/version'
|
||||||
require "mikunyan/asset"
|
|
||||||
require "mikunyan/binary_reader"
|
require 'mikunyan/asset_bundle'
|
||||||
require "mikunyan/object_value"
|
require 'mikunyan/asset'
|
||||||
require "mikunyan/type_tree"
|
require 'mikunyan/binary_reader'
|
||||||
require "mikunyan/constants"
|
require 'mikunyan/object_value'
|
||||||
|
require 'mikunyan/type_tree'
|
||||||
|
require 'mikunyan/constants'
|
||||||
|
|
||||||
# Module for deserializing Unity Assets and AssetBundles
|
# Module for deserializing Unity Assets and AssetBundles
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
|
|||||||
+24
-24
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
# Class for representing Unity Asset
|
# Class for representing Unity Asset
|
||||||
# @attr_reader [String] name Asset name
|
# @attr_reader [String] name Asset name
|
||||||
@@ -52,24 +54,24 @@ module Mikunyan
|
|||||||
# @param [String] file file name
|
# @param [String] file file name
|
||||||
# @param [String] name Asset name (automatically generated if not specified)
|
# @param [String] name Asset name (automatically generated if not specified)
|
||||||
# @return [Mikunyan::Asset] deserialized Asset object
|
# @return [Mikunyan::Asset] deserialized Asset object
|
||||||
def self.file(file, name=nil)
|
def self.file(file, name = nil)
|
||||||
name = File.basename(name, '.*') unless name
|
name ||= File.basename(name, '.*')
|
||||||
Asset.load(File.binread(file), name)
|
Asset.load(File.binread(file), name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns list of all path IDs
|
# Returns list of all path IDs
|
||||||
# @return [Array<Integer>] list of all path IDs
|
# @return [Array<Integer>] list of all path IDs
|
||||||
def path_ids
|
def path_ids
|
||||||
@objects.map{|e| e.path_id}
|
@objects.map(&:path_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns list of containers
|
# Returns list of containers
|
||||||
# @return [Array<Hash>,nil] list of all containers
|
# @return [Array<Hash>,nil] list of all containers
|
||||||
def containers
|
def containers
|
||||||
obj = parse_object(1)
|
obj = parse_object(1)
|
||||||
return nil unless obj && obj.m_Container && obj.m_Container.array?
|
return nil unless obj&.m_Container && obj.m_Container.array?
|
||||||
obj.m_Container.value.map do |e|
|
obj.m_Container.value.map do |e|
|
||||||
{:name => e.first.value, :preload_index => e.second.preloadIndex.value, :path_id => e.second.asset.m_PathID.value}
|
{ name: e.first.value, preload_index: e.second.preloadIndex.value, path_id: e.second.asset.m_PathID.value }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,12 +115,10 @@ module Mikunyan
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
klass = (obj.class_idx ? @klasses[obj.class_idx] : @klasses.find{|e| e.class_id == obj.class_id} || @klasses.find{|e| e.class_id == obj.type_id})
|
klass = (obj.class_idx ? @klasses[obj.class_idx] : @klasses.find{|e| e.class_id == obj.class_id} || @klasses.find{|e| e.class_id == obj.type_id})
|
||||||
if klass && klass.type_tree && klass.type_tree.nodes[0]
|
if klass&.type_tree && klass.type_tree.nodes[0]
|
||||||
klass.type_tree.nodes[0].type
|
klass.type_tree.nodes[0].type
|
||||||
elsif klass
|
elsif klass
|
||||||
Mikunyan::CLASS_ID[klass.class_id]
|
Mikunyan::CLASS_ID[klass.class_id]
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -153,10 +153,10 @@ module Mikunyan
|
|||||||
class_id = br.i32
|
class_id = br.i32
|
||||||
br.adv(1)
|
br.adv(1)
|
||||||
script_id = br.i16
|
script_id = br.i16
|
||||||
if class_id < 0 || class_id == 114
|
hash = if class_id < 0 || class_id == 114
|
||||||
hash = br.read(32)
|
br.read(32)
|
||||||
else
|
else
|
||||||
hash = br.read(16)
|
br.read(16)
|
||||||
end
|
end
|
||||||
@klasses << Klass.new(class_id, script_id, hash, has_type_trees ? TypeTree.load(br) : TypeTree.load_default(hash))
|
@klasses << Klass.new(class_id, script_id, hash, has_type_trees ? TypeTree.load(br) : TypeTree.load_default(hash))
|
||||||
end
|
end
|
||||||
@@ -165,10 +165,10 @@ module Mikunyan
|
|||||||
type_tree_count = br.i32u
|
type_tree_count = br.i32u
|
||||||
type_tree_count.times do
|
type_tree_count.times do
|
||||||
class_id = br.i32
|
class_id = br.i32
|
||||||
if class_id < 0
|
hash = if class_id < 0
|
||||||
hash = br.read(32)
|
br.read(32)
|
||||||
else
|
else
|
||||||
hash = br.read(16)
|
br.read(16)
|
||||||
end
|
end
|
||||||
@klasses << Klass.new(class_id, nil, hash, has_type_trees ? TypeTree.load(br) : TypeTree.load_default(hash))
|
@klasses << Klass.new(class_id, nil, hash, has_type_trees ? TypeTree.load(br) : TypeTree.load_default(hash))
|
||||||
end
|
end
|
||||||
@@ -190,10 +190,10 @@ module Mikunyan
|
|||||||
path_id = long_object_ids ? br.i64 : br.i32
|
path_id = long_object_ids ? br.i64 : br.i32
|
||||||
offset = br.i32u
|
offset = br.i32u
|
||||||
size = br.i32u
|
size = br.i32u
|
||||||
if @format >= 17
|
@objects << if @format >= 17
|
||||||
@objects << ObjectData.new(path_id, offset, size, nil, nil, br.i32u, @format <= 10 && br.i16 != 0)
|
ObjectData.new(path_id, offset, size, nil, nil, br.i32u, @format <= 10 && br.i16 != 0)
|
||||||
else
|
else
|
||||||
@objects << ObjectData.new(path_id, offset, size, br.i32, br.i16, nil, @format <= 10 && br.i16 != 0)
|
ObjectData.new(path_id, offset, size, br.i32, br.i16, nil, @format <= 10 && br.i16 != 0)
|
||||||
end
|
end
|
||||||
br.adv(2) if 11 <= @format && @format <= 16
|
br.adv(2) if 11 <= @format && @format <= 16
|
||||||
br.adv(1) if 15 <= @format && @format <= 16
|
br.adv(1) if 15 <= @format && @format <= 16
|
||||||
@@ -231,10 +231,10 @@ module Mikunyan
|
|||||||
data = nil
|
data = nil
|
||||||
size = parse_object_private(br, children.find{|e| e[:name] == 'size'}).value
|
size = parse_object_private(br, children.find{|e| e[:name] == 'size'}).value
|
||||||
data_type_tree = children.find{|e| e[:name] == 'data'}
|
data_type_tree = children.find{|e| e[:name] == 'data'}
|
||||||
if node.type == 'TypelessData'
|
data = if node.type == 'TypelessData'
|
||||||
data = br.read(size * data_type_tree[:node].size)
|
br.read(size * data_type_tree[:node].size)
|
||||||
else
|
else
|
||||||
data = size.times.map{ parse_object_private(br, data_type_tree) }
|
size.times.map{parse_object_private(br, data_type_tree)}
|
||||||
end
|
end
|
||||||
r = ObjectValue.new(node.name, node.type, br.endian, data)
|
r = ObjectValue.new(node.name, node.type, br.endian, data)
|
||||||
elsif node.size == -1
|
elsif node.size == -1
|
||||||
@@ -242,7 +242,7 @@ module Mikunyan
|
|||||||
if children.size == 1 && children[0][:name] == 'Array' && children[0][:node].type == 'Array' && children[0][:node].array?
|
if children.size == 1 && children[0][:name] == 'Array' && children[0][:node].type == 'Array' && children[0][:node].array?
|
||||||
if node.type == 'string'
|
if node.type == 'string'
|
||||||
size = parse_object_private(br, children[0][:children].find{|e| e[:name] == 'size'}).value
|
size = parse_object_private(br, children[0][:children].find{|e| e[:name] == 'size'}).value
|
||||||
r.value = br.read(size * children[0][:children].find{|e| e[:name] == 'data'}[:node].size).force_encoding("utf-8")
|
r.value = br.read(size * children[0][:children].find{|e| e[:name] == 'data'}[:node].size).force_encoding('utf-8')
|
||||||
br.align(4) if children[0][:node].flags & 0x4000 != 0
|
br.align(4) if children[0][:node].flags & 0x4000 != 0
|
||||||
else
|
else
|
||||||
r.value = parse_object_private(br, children[0]).value
|
r.value = parse_object_private(br, children[0]).value
|
||||||
@@ -255,7 +255,7 @@ module Mikunyan
|
|||||||
r[child[:name]] = parse_object_private(br, child)
|
r[child[:name]] = parse_object_private(br, child)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif children.size > 0
|
elsif !children.empty?
|
||||||
pos = br.pos
|
pos = br.pos
|
||||||
r = ObjectValue.new(node.name, node.type, br.endian)
|
r = ObjectValue.new(node.name, node.type, br.endian)
|
||||||
r.is_struct = true
|
r.is_struct = true
|
||||||
@@ -306,7 +306,7 @@ module Mikunyan
|
|||||||
elsif obj.type == 'pair'
|
elsif obj.type == 'pair'
|
||||||
[object_simplify(obj['first']), object_simplify(obj['second'])]
|
[object_simplify(obj['first']), object_simplify(obj['second'])]
|
||||||
elsif obj.type == 'map' && obj.array?
|
elsif obj.type == 'map' && obj.array?
|
||||||
obj.value.map{|e| [object_simplify(e['first']), object_simplify(e['second'])] }.to_h
|
obj.value.map{|e| [object_simplify(e['first']), object_simplify(e['second'])]}.to_h
|
||||||
elsif obj.value?
|
elsif obj.value?
|
||||||
object_simplify(obj.value)
|
object_simplify(obj.value)
|
||||||
elsif obj.array?
|
elsif obj.array?
|
||||||
@@ -326,7 +326,7 @@ module Mikunyan
|
|||||||
tree = {}
|
tree = {}
|
||||||
stack = []
|
stack = []
|
||||||
nodes.each do |node|
|
nodes.each do |node|
|
||||||
this = {:name => node.name, :node => node, :children => []}
|
this = { name: node.name, node: node, children: [] }
|
||||||
if node.depth == 0
|
if node.depth == 0
|
||||||
tree = this
|
tree = this
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'extlz4'
|
require 'extlz4'
|
||||||
require 'extlzma'
|
require 'extlzma'
|
||||||
|
|
||||||
@@ -61,9 +63,9 @@ module Mikunyan
|
|||||||
if compressed
|
if compressed
|
||||||
br.adv(4)
|
br.adv(4)
|
||||||
block_count = br.i32u
|
block_count = br.i32u
|
||||||
blocks = block_count.times.map{{ :c => br.i32u, :u => br.i32u }}
|
blocks = block_count.times.map{{ c: br.i32u, u: br.i32u }}
|
||||||
br.jmp(header_size)
|
br.jmp(header_size)
|
||||||
data = String.new
|
data = ''
|
||||||
blocks.each{|b| data << LZMA.decode(br.read(b[:c]))}
|
blocks.each{|b| data << LZMA.decode(br.read(b[:c]))}
|
||||||
br = BinaryReader.new(data)
|
br = BinaryReader.new(data)
|
||||||
else
|
else
|
||||||
@@ -96,13 +98,13 @@ module Mikunyan
|
|||||||
|
|
||||||
blocks = []
|
blocks = []
|
||||||
block_count = head.i32u
|
block_count = head.i32u
|
||||||
block_count.times{ blocks << {:u => head.i32u, :c => head.i32u, :f => head.i16u} }
|
block_count.times{blocks << { u: head.i32u, c: head.i32u, f: head.i16u }}
|
||||||
|
|
||||||
asset_blocks = []
|
asset_blocks = []
|
||||||
asset_count = head.i32u
|
asset_count = head.i32u
|
||||||
asset_count.times{ asset_blocks << {:offset => head.i64u, :size => head.i64u, :status => head.i32, :name => head.cstr} }
|
asset_count.times{asset_blocks << { offset: head.i64u, size: head.i64u, status: head.i32, name: head.cstr }}
|
||||||
|
|
||||||
raw_data = String.new
|
raw_data = ''
|
||||||
blocks.each{|b| raw_data << uncompress(br.read(b[:c]), b[:u], b[:f])}
|
blocks.each{|b| raw_data << uncompress(br.read(b[:c]), b[:u], b[:f])}
|
||||||
|
|
||||||
asset_blocks.each do |b|
|
asset_blocks.each do |b|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'bin_utils'
|
require 'bin_utils'
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
@@ -26,13 +28,13 @@ module Mikunyan
|
|||||||
|
|
||||||
# Jump to given position
|
# Jump to given position
|
||||||
# @param [Integer] pos position
|
# @param [Integer] pos position
|
||||||
def jmp(pos=0)
|
def jmp(pos = 0)
|
||||||
@pos = pos
|
@pos = pos
|
||||||
end
|
end
|
||||||
|
|
||||||
# Advance position given size
|
# Advance position given size
|
||||||
# @param [Integer] size size
|
# @param [Integer] size size
|
||||||
def adv(size=0)
|
def adv(size = 0)
|
||||||
@pos += size
|
@pos += size
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ module Mikunyan
|
|||||||
# Read string until null character
|
# Read string until null character
|
||||||
# @return [String] string
|
# @return [String] string
|
||||||
def cstr
|
def cstr
|
||||||
r = @data.unpack("@#{pos}Z*")[0]
|
r = @data.unpack1("@#{pos}Z*")
|
||||||
@pos += r.bytesize + 1
|
@pos += r.bytesize + 1
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
@@ -145,14 +147,14 @@ module Mikunyan
|
|||||||
|
|
||||||
# Read 32bit floating point value
|
# Read 32bit floating point value
|
||||||
def float
|
def float
|
||||||
r = little? ? @data.byteslice(@pos, 4).unpack('e')[0] : @data.byteslice(@pos, 4).unpack('g')[0]
|
r = little? ? @data.byteslice(@pos, 4).unpack1('e') : @data.byteslice(@pos, 4).unpack1('g')
|
||||||
@pos += 4
|
@pos += 4
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read 64bit floating point value
|
# Read 64bit floating point value
|
||||||
def double
|
def double
|
||||||
r = little? ? @data.byteslice(@pos, 8).unpack('E')[0] : @data.byteslice(@pos, 8).unpack('G')[0]
|
r = little? ? @data.byteslice(@pos, 8).unpack1('E') : @data.byteslice(@pos, 8).unpack1('G')
|
||||||
@pos += 8
|
@pos += 8
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
|
|||||||
+341
-338
@@ -1,344 +1,347 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
private
|
private
|
||||||
|
|
||||||
STRING_TABLE = {
|
STRING_TABLE = {
|
||||||
0=>'AABB',
|
0 => 'AABB',
|
||||||
5=>'AnimationClip',
|
5 => 'AnimationClip',
|
||||||
19=>'AnimationCurve',
|
19 => 'AnimationCurve',
|
||||||
34=>'AnimationState',
|
34 => 'AnimationState',
|
||||||
49=>'Array',
|
49 => 'Array',
|
||||||
55=>'Base',
|
55 => 'Base',
|
||||||
60=>'BitField',
|
60 => 'BitField',
|
||||||
69=>'bitset',
|
69 => 'bitset',
|
||||||
76=>'bool',
|
76 => 'bool',
|
||||||
81=>'char',
|
81 => 'char',
|
||||||
86=>'ColorRGBA',
|
86 => 'ColorRGBA',
|
||||||
96=>'Component',
|
96 => 'Component',
|
||||||
106=>'data',
|
106 => 'data',
|
||||||
111=>'deque',
|
111 => 'deque',
|
||||||
117=>'double',
|
117 => 'double',
|
||||||
124=>'dynamic_array',
|
124 => 'dynamic_array',
|
||||||
138=>'FastPropertyName',
|
138 => 'FastPropertyName',
|
||||||
155=>'first',
|
155 => 'first',
|
||||||
161=>'float',
|
161 => 'float',
|
||||||
167=>'Font',
|
167 => 'Font',
|
||||||
172=>'GameObject',
|
172 => 'GameObject',
|
||||||
183=>'Generic Mono',
|
183 => 'Generic Mono',
|
||||||
196=>'GradientNEW',
|
196 => 'GradientNEW',
|
||||||
208=>'GUID',
|
208 => 'GUID',
|
||||||
213=>'GUIStyle',
|
213 => 'GUIStyle',
|
||||||
222=>'int',
|
222 => 'int',
|
||||||
226=>'list',
|
226 => 'list',
|
||||||
231=>'long long',
|
231 => 'long long',
|
||||||
241=>'map',
|
241 => 'map',
|
||||||
245=>'Matrix4x4f',
|
245 => 'Matrix4x4f',
|
||||||
256=>'MdFour',
|
256 => 'MdFour',
|
||||||
263=>'MonoBehaviour',
|
263 => 'MonoBehaviour',
|
||||||
277=>'MonoScript',
|
277 => 'MonoScript',
|
||||||
288=>'m_ByteSize',
|
288 => 'm_ByteSize',
|
||||||
299=>'m_Curve',
|
299 => 'm_Curve',
|
||||||
307=>'m_EditorClassIdentifier',
|
307 => 'm_EditorClassIdentifier',
|
||||||
331=>'m_EditorHideFlags',
|
331 => 'm_EditorHideFlags',
|
||||||
349=>'m_Enabled',
|
349 => 'm_Enabled',
|
||||||
359=>'m_ExtensionPtr',
|
359 => 'm_ExtensionPtr',
|
||||||
374=>'m_GameObject',
|
374 => 'm_GameObject',
|
||||||
387=>'m_Index',
|
387 => 'm_Index',
|
||||||
395=>'m_IsArray',
|
395 => 'm_IsArray',
|
||||||
405=>'m_IsStatic',
|
405 => 'm_IsStatic',
|
||||||
416=>'m_MetaFlag',
|
416 => 'm_MetaFlag',
|
||||||
427=>'m_Name',
|
427 => 'm_Name',
|
||||||
434=>'m_ObjectHideFlags',
|
434 => 'm_ObjectHideFlags',
|
||||||
452=>'m_PrefabInternal',
|
452 => 'm_PrefabInternal',
|
||||||
469=>'m_PrefabParentObject',
|
469 => 'm_PrefabParentObject',
|
||||||
490=>'m_Script',
|
490 => 'm_Script',
|
||||||
499=>'m_StaticEditorFlags',
|
499 => 'm_StaticEditorFlags',
|
||||||
519=>'m_Type',
|
519 => 'm_Type',
|
||||||
526=>'m_Version',
|
526 => 'm_Version',
|
||||||
536=>'Object',
|
536 => 'Object',
|
||||||
543=>'pair',
|
543 => 'pair',
|
||||||
548=>'PPtr<Component>',
|
548 => 'PPtr<Component>',
|
||||||
564=>'PPtr<GameObject>',
|
564 => 'PPtr<GameObject>',
|
||||||
581=>'PPtr<Material>',
|
581 => 'PPtr<Material>',
|
||||||
596=>'PPtr<MonoBehaviour>',
|
596 => 'PPtr<MonoBehaviour>',
|
||||||
616=>'PPtr<MonoScript>',
|
616 => 'PPtr<MonoScript>',
|
||||||
633=>'PPtr<Object>',
|
633 => 'PPtr<Object>',
|
||||||
646=>'PPtr<Prefab>',
|
646 => 'PPtr<Prefab>',
|
||||||
659=>'PPtr<Sprite>',
|
659 => 'PPtr<Sprite>',
|
||||||
672=>'PPtr<TextAsset>',
|
672 => 'PPtr<TextAsset>',
|
||||||
688=>'PPtr<Texture>',
|
688 => 'PPtr<Texture>',
|
||||||
702=>'PPtr<Texture2D>',
|
702 => 'PPtr<Texture2D>',
|
||||||
718=>'PPtr<Transform>',
|
718 => 'PPtr<Transform>',
|
||||||
734=>'Prefab',
|
734 => 'Prefab',
|
||||||
741=>'Quaternionf',
|
741 => 'Quaternionf',
|
||||||
753=>'Rectf',
|
753 => 'Rectf',
|
||||||
759=>'RectInt',
|
759 => 'RectInt',
|
||||||
767=>'RectOffset',
|
767 => 'RectOffset',
|
||||||
778=>'second',
|
778 => 'second',
|
||||||
785=>'set',
|
785 => 'set',
|
||||||
789=>'short',
|
789 => 'short',
|
||||||
795=>'size',
|
795 => 'size',
|
||||||
800=>'SInt16',
|
800 => 'SInt16',
|
||||||
807=>'SInt32',
|
807 => 'SInt32',
|
||||||
814=>'SInt64',
|
814 => 'SInt64',
|
||||||
821=>'SInt8',
|
821 => 'SInt8',
|
||||||
827=>'staticvector',
|
827 => 'staticvector',
|
||||||
840=>'string',
|
840 => 'string',
|
||||||
847=>'TextAsset',
|
847 => 'TextAsset',
|
||||||
857=>'TextMesh',
|
857 => 'TextMesh',
|
||||||
866=>'Texture',
|
866 => 'Texture',
|
||||||
874=>'Texture2D',
|
874 => 'Texture2D',
|
||||||
884=>'Transform',
|
884 => 'Transform',
|
||||||
894=>'TypelessData',
|
894 => 'TypelessData',
|
||||||
907=>'UInt16',
|
907 => 'UInt16',
|
||||||
914=>'UInt32',
|
914 => 'UInt32',
|
||||||
921=>'UInt64',
|
921 => 'UInt64',
|
||||||
928=>'UInt8',
|
928 => 'UInt8',
|
||||||
934=>'unsigned int',
|
934 => 'unsigned int',
|
||||||
947=>'unsigned long long',
|
947 => 'unsigned long long',
|
||||||
966=>'unsigned short',
|
966 => 'unsigned short',
|
||||||
981=>'vector',
|
981 => 'vector',
|
||||||
988=>'Vector2f',
|
988 => 'Vector2f',
|
||||||
997=>'Vector3f',
|
997 => 'Vector3f',
|
||||||
1006=>'Vector4f',
|
1006 => 'Vector4f',
|
||||||
1015=>'m_ScriptingClassIdentifier',
|
1015 => 'm_ScriptingClassIdentifier',
|
||||||
1042=>'Gradient'
|
1042 => 'Gradient'
|
||||||
}
|
}.freeze
|
||||||
|
|
||||||
CLASS_ID = {
|
CLASS_ID = {
|
||||||
1=>'GameObject',
|
1 => 'GameObject',
|
||||||
2=>'Component',
|
2 => 'Component',
|
||||||
3=>'LevelGameManager',
|
3 => 'LevelGameManager',
|
||||||
4=>'Transform',
|
4 => 'Transform',
|
||||||
5=>'TimeManager',
|
5 => 'TimeManager',
|
||||||
6=>'GlobalGameManager',
|
6 => 'GlobalGameManager',
|
||||||
8=>'Behaviour',
|
8 => 'Behaviour',
|
||||||
9=>'GameManager',
|
9 => 'GameManager',
|
||||||
11=>'AudioManager',
|
11 => 'AudioManager',
|
||||||
12=>'ParticleAnimator',
|
12 => 'ParticleAnimator',
|
||||||
13=>'InputManager',
|
13 => 'InputManager',
|
||||||
15=>'EllipsoidParticleEmitter',
|
15 => 'EllipsoidParticleEmitter',
|
||||||
17=>'Pipeline',
|
17 => 'Pipeline',
|
||||||
18=>'EditorExtension',
|
18 => 'EditorExtension',
|
||||||
19=>'Physics2DSettings',
|
19 => 'Physics2DSettings',
|
||||||
20=>'Camera',
|
20 => 'Camera',
|
||||||
21=>'Material',
|
21 => 'Material',
|
||||||
23=>'MeshRenderer',
|
23 => 'MeshRenderer',
|
||||||
25=>'Renderer',
|
25 => 'Renderer',
|
||||||
26=>'ParticleRenderer',
|
26 => 'ParticleRenderer',
|
||||||
27=>'Texture',
|
27 => 'Texture',
|
||||||
28=>'Texture2D',
|
28 => 'Texture2D',
|
||||||
29=>'SceneSettings',
|
29 => 'SceneSettings',
|
||||||
30=>'GraphicsSettings',
|
30 => 'GraphicsSettings',
|
||||||
33=>'MeshFilter',
|
33 => 'MeshFilter',
|
||||||
41=>'OcclusionPortal',
|
41 => 'OcclusionPortal',
|
||||||
43=>'Mesh',
|
43 => 'Mesh',
|
||||||
45=>'Skybox',
|
45 => 'Skybox',
|
||||||
47=>'QualitySettings',
|
47 => 'QualitySettings',
|
||||||
48=>'Shader',
|
48 => 'Shader',
|
||||||
49=>'TextAsset',
|
49 => 'TextAsset',
|
||||||
50=>'Rigidbody2D',
|
50 => 'Rigidbody2D',
|
||||||
51=>'Physics2DManager',
|
51 => 'Physics2DManager',
|
||||||
53=>'Collider2D',
|
53 => 'Collider2D',
|
||||||
54=>'Rigidbody',
|
54 => 'Rigidbody',
|
||||||
55=>'PhysicsManager',
|
55 => 'PhysicsManager',
|
||||||
56=>'Collider',
|
56 => 'Collider',
|
||||||
57=>'Joint',
|
57 => 'Joint',
|
||||||
58=>'CircleCollider2D',
|
58 => 'CircleCollider2D',
|
||||||
59=>'HingeJoint',
|
59 => 'HingeJoint',
|
||||||
60=>'PolygonCollider2D',
|
60 => 'PolygonCollider2D',
|
||||||
61=>'BoxCollider2D',
|
61 => 'BoxCollider2D',
|
||||||
62=>'PhysicsMaterial2D',
|
62 => 'PhysicsMaterial2D',
|
||||||
64=>'MeshCollider',
|
64 => 'MeshCollider',
|
||||||
65=>'BoxCollider',
|
65 => 'BoxCollider',
|
||||||
66=>'SpriteCollider2D',
|
66 => 'SpriteCollider2D',
|
||||||
68=>'EdgeCollider2D',
|
68 => 'EdgeCollider2D',
|
||||||
72=>'ComputeShader',
|
72 => 'ComputeShader',
|
||||||
74=>'AnimationClip',
|
74 => 'AnimationClip',
|
||||||
75=>'ConstantForce',
|
75 => 'ConstantForce',
|
||||||
76=>'WorldParticleCollider',
|
76 => 'WorldParticleCollider',
|
||||||
78=>'TagManager',
|
78 => 'TagManager',
|
||||||
81=>'AudioListener',
|
81 => 'AudioListener',
|
||||||
82=>'AudioSource',
|
82 => 'AudioSource',
|
||||||
83=>'AudioClip',
|
83 => 'AudioClip',
|
||||||
84=>'RenderTexture',
|
84 => 'RenderTexture',
|
||||||
87=>'MeshParticleEmitter',
|
87 => 'MeshParticleEmitter',
|
||||||
88=>'ParticleEmitter',
|
88 => 'ParticleEmitter',
|
||||||
89=>'Cubemap',
|
89 => 'Cubemap',
|
||||||
90=>'Avatar',
|
90 => 'Avatar',
|
||||||
91=>'AnimatorController',
|
91 => 'AnimatorController',
|
||||||
92=>'GUILayer',
|
92 => 'GUILayer',
|
||||||
93=>'RuntimeAnimatorController',
|
93 => 'RuntimeAnimatorController',
|
||||||
94=>'ScriptMapper',
|
94 => 'ScriptMapper',
|
||||||
95=>'Animator',
|
95 => 'Animator',
|
||||||
96=>'TrailRenderer',
|
96 => 'TrailRenderer',
|
||||||
98=>'DelayedCallManager',
|
98 => 'DelayedCallManager',
|
||||||
102=>'TextMesh',
|
102 => 'TextMesh',
|
||||||
104=>'RenderSettings',
|
104 => 'RenderSettings',
|
||||||
108=>'Light',
|
108 => 'Light',
|
||||||
109=>'CGProgram',
|
109 => 'CGProgram',
|
||||||
110=>'BaseAnimationTrack',
|
110 => 'BaseAnimationTrack',
|
||||||
111=>'Animation',
|
111 => 'Animation',
|
||||||
114=>'MonoBehaviour',
|
114 => 'MonoBehaviour',
|
||||||
115=>'MonoScript',
|
115 => 'MonoScript',
|
||||||
116=>'MonoManager',
|
116 => 'MonoManager',
|
||||||
117=>'Texture3D',
|
117 => 'Texture3D',
|
||||||
118=>'NewAnimationTrack',
|
118 => 'NewAnimationTrack',
|
||||||
119=>'Projector',
|
119 => 'Projector',
|
||||||
120=>'LineRenderer',
|
120 => 'LineRenderer',
|
||||||
121=>'Flare',
|
121 => 'Flare',
|
||||||
122=>'Halo',
|
122 => 'Halo',
|
||||||
123=>'LensFlare',
|
123 => 'LensFlare',
|
||||||
124=>'FlareLayer',
|
124 => 'FlareLayer',
|
||||||
125=>'HaloLayer',
|
125 => 'HaloLayer',
|
||||||
126=>'NavMeshAreas',
|
126 => 'NavMeshAreas',
|
||||||
127=>'HaloManager',
|
127 => 'HaloManager',
|
||||||
128=>'Font',
|
128 => 'Font',
|
||||||
129=>'PlayerSettings',
|
129 => 'PlayerSettings',
|
||||||
130=>'NamedObject',
|
130 => 'NamedObject',
|
||||||
131=>'GUITexture',
|
131 => 'GUITexture',
|
||||||
132=>'GUIText',
|
132 => 'GUIText',
|
||||||
133=>'GUIElement',
|
133 => 'GUIElement',
|
||||||
134=>'PhysicMaterial',
|
134 => 'PhysicMaterial',
|
||||||
135=>'SphereCollider',
|
135 => 'SphereCollider',
|
||||||
136=>'CapsuleCollider',
|
136 => 'CapsuleCollider',
|
||||||
137=>'SkinnedMeshRenderer',
|
137 => 'SkinnedMeshRenderer',
|
||||||
138=>'FixedJoint',
|
138 => 'FixedJoint',
|
||||||
140=>'RaycastCollider',
|
140 => 'RaycastCollider',
|
||||||
141=>'BuildSettings',
|
141 => 'BuildSettings',
|
||||||
142=>'AssetBundle',
|
142 => 'AssetBundle',
|
||||||
143=>'CharacterController',
|
143 => 'CharacterController',
|
||||||
144=>'CharacterJoint',
|
144 => 'CharacterJoint',
|
||||||
145=>'SpringJoint',
|
145 => 'SpringJoint',
|
||||||
146=>'WheelCollider',
|
146 => 'WheelCollider',
|
||||||
147=>'ResourceManager',
|
147 => 'ResourceManager',
|
||||||
148=>'NetworkView',
|
148 => 'NetworkView',
|
||||||
149=>'NetworkManager',
|
149 => 'NetworkManager',
|
||||||
150=>'PreloadData',
|
150 => 'PreloadData',
|
||||||
152=>'MovieTexture',
|
152 => 'MovieTexture',
|
||||||
153=>'ConfigurableJoint',
|
153 => 'ConfigurableJoint',
|
||||||
154=>'TerrainCollider',
|
154 => 'TerrainCollider',
|
||||||
155=>'MasterServerInterface',
|
155 => 'MasterServerInterface',
|
||||||
156=>'TerrainData',
|
156 => 'TerrainData',
|
||||||
157=>'LightmapSettings',
|
157 => 'LightmapSettings',
|
||||||
158=>'WebCamTexture',
|
158 => 'WebCamTexture',
|
||||||
159=>'EditorSettings',
|
159 => 'EditorSettings',
|
||||||
160=>'InteractiveCloth',
|
160 => 'InteractiveCloth',
|
||||||
161=>'ClothRenderer',
|
161 => 'ClothRenderer',
|
||||||
162=>'EditorUserSettings',
|
162 => 'EditorUserSettings',
|
||||||
163=>'SkinnedCloth',
|
163 => 'SkinnedCloth',
|
||||||
164=>'AudioReverbFilter',
|
164 => 'AudioReverbFilter',
|
||||||
165=>'AudioHighPassFilter',
|
165 => 'AudioHighPassFilter',
|
||||||
166=>'AudioChorusFilter',
|
166 => 'AudioChorusFilter',
|
||||||
167=>'AudioReverbZone',
|
167 => 'AudioReverbZone',
|
||||||
168=>'AudioEchoFilter',
|
168 => 'AudioEchoFilter',
|
||||||
169=>'AudioLowPassFilter',
|
169 => 'AudioLowPassFilter',
|
||||||
170=>'AudioDistortionFilter',
|
170 => 'AudioDistortionFilter',
|
||||||
171=>'SparseTexture',
|
171 => 'SparseTexture',
|
||||||
180=>'AudioBehaviour',
|
180 => 'AudioBehaviour',
|
||||||
181=>'AudioFilter',
|
181 => 'AudioFilter',
|
||||||
182=>'WindZone',
|
182 => 'WindZone',
|
||||||
183=>'Cloth',
|
183 => 'Cloth',
|
||||||
184=>'SubstanceArchive',
|
184 => 'SubstanceArchive',
|
||||||
185=>'ProceduralMaterial',
|
185 => 'ProceduralMaterial',
|
||||||
186=>'ProceduralTexture',
|
186 => 'ProceduralTexture',
|
||||||
191=>'OffMeshLink',
|
191 => 'OffMeshLink',
|
||||||
192=>'OcclusionArea',
|
192 => 'OcclusionArea',
|
||||||
193=>'Tree',
|
193 => 'Tree',
|
||||||
194=>'NavMeshObsolete',
|
194 => 'NavMeshObsolete',
|
||||||
195=>'NavMeshAgent',
|
195 => 'NavMeshAgent',
|
||||||
196=>'NavMeshSettings',
|
196 => 'NavMeshSettings',
|
||||||
197=>'LightProbesLegacy',
|
197 => 'LightProbesLegacy',
|
||||||
198=>'ParticleSystem',
|
198 => 'ParticleSystem',
|
||||||
199=>'ParticleSystemRenderer',
|
199 => 'ParticleSystemRenderer',
|
||||||
200=>'ShaderVariantCollection',
|
200 => 'ShaderVariantCollection',
|
||||||
205=>'LODGroup',
|
205 => 'LODGroup',
|
||||||
206=>'BlendTree',
|
206 => 'BlendTree',
|
||||||
207=>'Motion',
|
207 => 'Motion',
|
||||||
208=>'NavMeshObstacle',
|
208 => 'NavMeshObstacle',
|
||||||
210=>'TerrainInstance',
|
210 => 'TerrainInstance',
|
||||||
212=>'SpriteRenderer',
|
212 => 'SpriteRenderer',
|
||||||
213=>'Sprite',
|
213 => 'Sprite',
|
||||||
214=>'CachedSpriteAtlas',
|
214 => 'CachedSpriteAtlas',
|
||||||
215=>'ReflectionProbe',
|
215 => 'ReflectionProbe',
|
||||||
216=>'ReflectionProbes',
|
216 => 'ReflectionProbes',
|
||||||
218=>'Terrain',
|
218 => 'Terrain',
|
||||||
220=>'LightProbeGroup',
|
220 => 'LightProbeGroup',
|
||||||
221=>'AnimatorOverrideController',
|
221 => 'AnimatorOverrideController',
|
||||||
222=>'CanvasRenderer',
|
222 => 'CanvasRenderer',
|
||||||
223=>'Canvas',
|
223 => 'Canvas',
|
||||||
224=>'RectTransform',
|
224 => 'RectTransform',
|
||||||
225=>'CanvasGroup',
|
225 => 'CanvasGroup',
|
||||||
226=>'BillboardAsset',
|
226 => 'BillboardAsset',
|
||||||
227=>'BillboardRenderer',
|
227 => 'BillboardRenderer',
|
||||||
228=>'SpeedTreeWindAsset',
|
228 => 'SpeedTreeWindAsset',
|
||||||
229=>'AnchoredJoint2D',
|
229 => 'AnchoredJoint2D',
|
||||||
230=>'Joint2D',
|
230 => 'Joint2D',
|
||||||
231=>'SpringJoint2D',
|
231 => 'SpringJoint2D',
|
||||||
232=>'DistanceJoint2D',
|
232 => 'DistanceJoint2D',
|
||||||
233=>'HingeJoint2D',
|
233 => 'HingeJoint2D',
|
||||||
234=>'SliderJoint2D',
|
234 => 'SliderJoint2D',
|
||||||
235=>'WheelJoint2D',
|
235 => 'WheelJoint2D',
|
||||||
238=>'NavMeshData',
|
238 => 'NavMeshData',
|
||||||
240=>'AudioMixer',
|
240 => 'AudioMixer',
|
||||||
241=>'AudioMixerController',
|
241 => 'AudioMixerController',
|
||||||
243=>'AudioMixerGroupController',
|
243 => 'AudioMixerGroupController',
|
||||||
244=>'AudioMixerEffectController',
|
244 => 'AudioMixerEffectController',
|
||||||
245=>'AudioMixerSnapshotController',
|
245 => 'AudioMixerSnapshotController',
|
||||||
246=>'PhysicsUpdateBehaviour2D',
|
246 => 'PhysicsUpdateBehaviour2D',
|
||||||
247=>'ConstantForce2D',
|
247 => 'ConstantForce2D',
|
||||||
248=>'Effector2D',
|
248 => 'Effector2D',
|
||||||
249=>'AreaEffector2D',
|
249 => 'AreaEffector2D',
|
||||||
250=>'PointEffector2D',
|
250 => 'PointEffector2D',
|
||||||
251=>'PlatformEffector2D',
|
251 => 'PlatformEffector2D',
|
||||||
252=>'SurfaceEffector2D',
|
252 => 'SurfaceEffector2D',
|
||||||
258=>'LightProbes',
|
258 => 'LightProbes',
|
||||||
271=>'SampleClip',
|
271 => 'SampleClip',
|
||||||
272=>'AudioMixerSnapshot',
|
272 => 'AudioMixerSnapshot',
|
||||||
273=>'AudioMixerGroup',
|
273 => 'AudioMixerGroup',
|
||||||
290=>'AssetBundleManifest',
|
290 => 'AssetBundleManifest',
|
||||||
1001=>'Prefab',
|
1001 => 'Prefab',
|
||||||
1002=>'EditorExtensionImpl',
|
1002 => 'EditorExtensionImpl',
|
||||||
1003=>'AssetImporter',
|
1003 => 'AssetImporter',
|
||||||
1004=>'AssetDatabase',
|
1004 => 'AssetDatabase',
|
||||||
1005=>'Mesh3DSImporter',
|
1005 => 'Mesh3DSImporter',
|
||||||
1006=>'TextureImporter',
|
1006 => 'TextureImporter',
|
||||||
1007=>'ShaderImporter',
|
1007 => 'ShaderImporter',
|
||||||
1008=>'ComputeShaderImporter',
|
1008 => 'ComputeShaderImporter',
|
||||||
1011=>'AvatarMask',
|
1011 => 'AvatarMask',
|
||||||
1020=>'AudioImporter',
|
1020 => 'AudioImporter',
|
||||||
1026=>'HierarchyState',
|
1026 => 'HierarchyState',
|
||||||
1027=>'GUIDSerializer',
|
1027 => 'GUIDSerializer',
|
||||||
1028=>'AssetMetaData',
|
1028 => 'AssetMetaData',
|
||||||
1029=>'DefaultAsset',
|
1029 => 'DefaultAsset',
|
||||||
1030=>'DefaultImporter',
|
1030 => 'DefaultImporter',
|
||||||
1031=>'TextScriptImporter',
|
1031 => 'TextScriptImporter',
|
||||||
1032=>'SceneAsset',
|
1032 => 'SceneAsset',
|
||||||
1034=>'NativeFormatImporter',
|
1034 => 'NativeFormatImporter',
|
||||||
1035=>'MonoImporter',
|
1035 => 'MonoImporter',
|
||||||
1037=>'AssetServerCache',
|
1037 => 'AssetServerCache',
|
||||||
1038=>'LibraryAssetImporter',
|
1038 => 'LibraryAssetImporter',
|
||||||
1040=>'ModelImporter',
|
1040 => 'ModelImporter',
|
||||||
1041=>'FBXImporter',
|
1041 => 'FBXImporter',
|
||||||
1042=>'TrueTypeFontImporter',
|
1042 => 'TrueTypeFontImporter',
|
||||||
1044=>'MovieImporter',
|
1044 => 'MovieImporter',
|
||||||
1045=>'EditorBuildSettings',
|
1045 => 'EditorBuildSettings',
|
||||||
1046=>'DDSImporter',
|
1046 => 'DDSImporter',
|
||||||
1048=>'InspectorExpandedState',
|
1048 => 'InspectorExpandedState',
|
||||||
1049=>'AnnotationManager',
|
1049 => 'AnnotationManager',
|
||||||
1050=>'PluginImporter',
|
1050 => 'PluginImporter',
|
||||||
1051=>'EditorUserBuildSettings',
|
1051 => 'EditorUserBuildSettings',
|
||||||
1052=>'PVRImporter',
|
1052 => 'PVRImporter',
|
||||||
1053=>'ASTCImporter',
|
1053 => 'ASTCImporter',
|
||||||
1054=>'KTXImporter',
|
1054 => 'KTXImporter',
|
||||||
1101=>'AnimatorStateTransition',
|
1101 => 'AnimatorStateTransition',
|
||||||
1102=>'AnimatorState',
|
1102 => 'AnimatorState',
|
||||||
1105=>'HumanTemplate',
|
1105 => 'HumanTemplate',
|
||||||
1107=>'AnimatorStateMachine',
|
1107 => 'AnimatorStateMachine',
|
||||||
1108=>'PreviewAssetType',
|
1108 => 'PreviewAssetType',
|
||||||
1109=>'AnimatorTransition',
|
1109 => 'AnimatorTransition',
|
||||||
1110=>'SpeedTreeImporter',
|
1110 => 'SpeedTreeImporter',
|
||||||
1111=>'AnimatorTransitionBase',
|
1111 => 'AnimatorTransitionBase',
|
||||||
1112=>'SubstanceImporter',
|
1112 => 'SubstanceImporter',
|
||||||
1113=>'LightmapParameters',
|
1113 => 'LightmapParameters',
|
||||||
1120=>'LightmapSnapshot'
|
1120 => 'LightmapSnapshot'
|
||||||
}
|
}.freeze
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'mikunyan/decoders/image_decoder'
|
require 'mikunyan/decoders/image_decoder'
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
begin; require 'oily_png'; rescue LoadError; require 'chunky_png'; end
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'oily_png'
|
||||||
|
rescue LoadError
|
||||||
|
require 'chunky_png'
|
||||||
|
end
|
||||||
require 'bin_utils'
|
require 'bin_utils'
|
||||||
require 'mikunyan/decoders/native'
|
require 'mikunyan/decoders/native'
|
||||||
|
|
||||||
@@ -23,7 +29,7 @@ module Mikunyan
|
|||||||
bin = bin.value
|
bin = bin.value
|
||||||
fmt = fmt.value
|
fmt = fmt.value
|
||||||
|
|
||||||
if bin.size == 0 && object['m_StreamData']
|
if bin.empty? && object['m_StreamData']
|
||||||
bin = object['m_StreamData'].value
|
bin = object['m_StreamData'].value
|
||||||
return nil unless bin
|
return nil unless bin
|
||||||
end
|
end
|
||||||
@@ -89,8 +95,6 @@ module Mikunyan
|
|||||||
decode_rg16(width, height, bin)
|
decode_rg16(width, height, bin)
|
||||||
when 63
|
when 63
|
||||||
decode_r8(width, height, bin)
|
decode_r8(width, height, bin)
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -103,7 +107,7 @@ module Mikunyan
|
|||||||
def self.decode_rgba4444(width, height, bin, endian = :big)
|
def self.decode_rgba4444(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 4)
|
mem = String.new(capacity: width * height * 4)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = endian == :little ? BinUtils.get_int16_le(bin, i*2) : BinUtils.get_int16_be(bin, i*2)
|
c = endian == :little ? BinUtils.get_int16_le(bin, i * 2) : BinUtils.get_int16_be(bin, i * 2)
|
||||||
c = ((c & 0xf000) << 12) | ((c & 0x0f00) << 8) | ((c & 0x00f0) << 4) | (c & 0x000f)
|
c = ((c & 0xf000) << 12) | ((c & 0x0f00) << 8) | ((c & 0x00f0) << 4) | (c & 0x000f)
|
||||||
BinUtils.append_int32_be!(mem, c << 4 | c)
|
BinUtils.append_int32_be!(mem, c << 4 | c)
|
||||||
end
|
end
|
||||||
@@ -119,7 +123,7 @@ module Mikunyan
|
|||||||
def self.decode_argb4444(width, height, bin, endian = :big)
|
def self.decode_argb4444(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 4)
|
mem = String.new(capacity: width * height * 4)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = endian == :little ? BinUtils.get_int16_le(bin, i*2) : BinUtils.get_int16_be(bin, i*2)
|
c = endian == :little ? BinUtils.get_int16_le(bin, i * 2) : BinUtils.get_int16_be(bin, i * 2)
|
||||||
c = ((c & 0x0f00) << 16) | ((c & 0x00f0) << 12) | ((c & 0x000f) << 8) | ((c & 0xf000) >> 12)
|
c = ((c & 0x0f00) << 16) | ((c & 0x00f0) << 12) | ((c & 0x000f) << 8) | ((c & 0xf000) >> 12)
|
||||||
BinUtils.append_int32_be!(mem, c << 4 | c)
|
BinUtils.append_int32_be!(mem, c << 4 | c)
|
||||||
end
|
end
|
||||||
@@ -167,7 +171,7 @@ module Mikunyan
|
|||||||
def self.decode_rg16(width, height, bin)
|
def self.decode_rg16(width, height, bin)
|
||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
BinUtils.append_int16_int8_be!(mem, BinUtils.get_int16_be(bin, i*2), 0)
|
BinUtils.append_int16_int8_be!(mem, BinUtils.get_int16_be(bin, i * 2), 0)
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
||||||
end
|
end
|
||||||
@@ -198,7 +202,7 @@ module Mikunyan
|
|||||||
def self.decode_argb32(width, height, bin)
|
def self.decode_argb32(width, height, bin)
|
||||||
mem = String.new(capacity: width * height * 4)
|
mem = String.new(capacity: width * height * 4)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = BinUtils.get_int32_be(bin, i*4)
|
c = BinUtils.get_int32_be(bin, i * 4)
|
||||||
BinUtils.append_int32_be!(mem, ((c & 0x00ffffff) << 8) | ((c & 0xff000000) >> 24))
|
BinUtils.append_int32_be!(mem, ((c & 0x00ffffff) << 8) | ((c & 0xff000000) >> 24))
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
||||||
@@ -212,7 +216,7 @@ module Mikunyan
|
|||||||
def self.decode_bgra32(width, height, bin)
|
def self.decode_bgra32(width, height, bin)
|
||||||
mem = String.new(capacity: width * height * 4)
|
mem = String.new(capacity: width * height * 4)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = BinUtils.get_int32_le(bin, i*4)
|
c = BinUtils.get_int32_le(bin, i * 4)
|
||||||
BinUtils.append_int32_be!(mem, ((c & 0x00ffffff) << 8) | ((c & 0xff000000) >> 24))
|
BinUtils.append_int32_be!(mem, ((c & 0x00ffffff) << 8) | ((c & 0xff000000) >> 24))
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
||||||
@@ -227,7 +231,7 @@ module Mikunyan
|
|||||||
def self.decode_r16(width, height, bin, endian = :big)
|
def self.decode_r16(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = endian == :little ? BinUtils.get_int16_le(bin, i*2) : BinUtils.get_int16_be(bin, i*2)
|
c = endian == :little ? BinUtils.get_int16_le(bin, i * 2) : BinUtils.get_int16_be(bin, i * 2)
|
||||||
c = f2i(r / 65535.0)
|
c = f2i(r / 65535.0)
|
||||||
BinUtils.append_int8!(mem, c, c, c)
|
BinUtils.append_int8!(mem, c, c, c)
|
||||||
end
|
end
|
||||||
@@ -243,14 +247,14 @@ module Mikunyan
|
|||||||
def self.decode_rgb9e5float(width, height, bin, endian = :big)
|
def self.decode_rgb9e5float(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
n = endian == :little ? BinUtils.get_int32_le(bin, i*4) : BinUtils.get_int32_be(bin, i*4)
|
n = endian == :little ? BinUtils.get_int32_le(bin, i * 4) : BinUtils.get_int32_be(bin, i * 4)
|
||||||
e = (n & 0xf8000000) >> 27
|
e = (n & 0xf8000000) >> 27
|
||||||
r = (n & 0x7fc0000) >> 9
|
r = (n & 0x7fc0000) >> 9
|
||||||
g = (n & 0x3fe00) >> 9
|
g = (n & 0x3fe00) >> 9
|
||||||
b = n & 0x1ff
|
b = n & 0x1ff
|
||||||
r = (r / 512r + 1) * (2**(e-15))
|
r = (r / 512r + 1) * (2**(e - 15))
|
||||||
g = (g / 512r + 1) * (2**(e-15))
|
g = (g / 512r + 1) * (2**(e - 15))
|
||||||
b = (b / 512r + 1) * (2**(e-15))
|
b = (b / 512r + 1) * (2**(e - 15))
|
||||||
BinUtils.append_int8!(mem, f2i(r), f2i(g), f2i(b))
|
BinUtils.append_int8!(mem, f2i(r), f2i(g), f2i(b))
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
||||||
@@ -265,7 +269,7 @@ module Mikunyan
|
|||||||
def self.decode_rhalf(width, height, bin, endian = :big)
|
def self.decode_rhalf(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*2) : BinUtils.get_int16_be(bin, i*2)))
|
c = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 2) : BinUtils.get_int16_be(bin, i * 2)))
|
||||||
BinUtils.append_int8!(mem, c, c, c)
|
BinUtils.append_int8!(mem, c, c, c)
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
||||||
@@ -280,8 +284,8 @@ module Mikunyan
|
|||||||
def self.decode_rghalf(width, height, bin, endian = :big)
|
def self.decode_rghalf(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
r = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*4) : BinUtils.get_int16_be(bin, i*4)))
|
r = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 4) : BinUtils.get_int16_be(bin, i * 4)))
|
||||||
g = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*4+2) : BinUtils.get_int16_be(bin, i*4+2)))
|
g = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 4 + 2) : BinUtils.get_int16_be(bin, i * 4 + 2)))
|
||||||
BinUtils.append_int8!(mem, r, g, 0)
|
BinUtils.append_int8!(mem, r, g, 0)
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
||||||
@@ -296,10 +300,10 @@ module Mikunyan
|
|||||||
def self.decode_rgbahalf(width, height, bin, endian = :big)
|
def self.decode_rgbahalf(width, height, bin, endian = :big)
|
||||||
mem = String.new(capacity: width * height * 4)
|
mem = String.new(capacity: width * height * 4)
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
r = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*8) : BinUtils.get_int16_be(bin, i*8)))
|
r = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 8) : BinUtils.get_int16_be(bin, i * 8)))
|
||||||
g = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*8+2) : BinUtils.get_int16_be(bin, i*8+2)))
|
g = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 8 + 2) : BinUtils.get_int16_be(bin, i * 8 + 2)))
|
||||||
b = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*8+4) : BinUtils.get_int16_be(bin, i*8+4)))
|
b = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 8 + 4) : BinUtils.get_int16_be(bin, i * 8 + 4)))
|
||||||
a = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*8+6) : BinUtils.get_int16_be(bin, i*8+6)))
|
a = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i * 8 + 6) : BinUtils.get_int16_be(bin, i * 8 + 6)))
|
||||||
BinUtils.append_int8!(mem, r, g, b, a)
|
BinUtils.append_int8!(mem, r, g, b, a)
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
||||||
@@ -315,7 +319,7 @@ module Mikunyan
|
|||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
unpackstr = endian == :little ? 'e' : 'g'
|
unpackstr = endian == :little ? 'e' : 'g'
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
c = f2i(bin.byteslice(i*4, 4).unpack(unpackstr)[0])
|
c = f2i(bin.byteslice(i * 4, 4).unpack1(unpackstr))
|
||||||
BinUtils.append_int8!(mem, c, c, c)
|
BinUtils.append_int8!(mem, c, c, c)
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
||||||
@@ -331,7 +335,7 @@ module Mikunyan
|
|||||||
mem = String.new(capacity: width * height * 3)
|
mem = String.new(capacity: width * height * 3)
|
||||||
unpackstr = endian == :little ? 'e2' : 'g2'
|
unpackstr = endian == :little ? 'e2' : 'g2'
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
r, g = bin.byteslice(i*8, 8).unpack(unpackstr)
|
r, g = bin.byteslice(i * 8, 8).unpack(unpackstr)
|
||||||
BinUtils.append_int8!(mem, f2i(r), f2i(g), 0)
|
BinUtils.append_int8!(mem, f2i(r), f2i(g), 0)
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
||||||
@@ -347,7 +351,7 @@ module Mikunyan
|
|||||||
mem = String.new(capacity: width * height * 4)
|
mem = String.new(capacity: width * height * 4)
|
||||||
unpackstr = endian == :little ? 'e4' : 'g4'
|
unpackstr = endian == :little ? 'e4' : 'g4'
|
||||||
(width * height).times do |i|
|
(width * height).times do |i|
|
||||||
r, g, b, a = bin.byteslice(i*16, 16).unpack(unpackstr)
|
r, g, b, a = bin.byteslice(i * 16, 16).unpack(unpackstr)
|
||||||
BinUtils.append_int8!(mem, f2i(r), f2i(g), f2i(b), f2i(a))
|
BinUtils.append_int8!(mem, f2i(r), f2i(g), f2i(b), f2i(a))
|
||||||
end
|
end
|
||||||
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
||||||
@@ -435,13 +439,11 @@ module Mikunyan
|
|||||||
bin = bin.value if bin.class == ObjectValue
|
bin = bin.value if bin.class == ObjectValue
|
||||||
if width && height && fmt && astc_list[fmt]
|
if width && height && fmt && astc_list[fmt]
|
||||||
header = "\x13\xAB\xA1\x5C".force_encoding('ascii-8bit')
|
header = "\x13\xAB\xA1\x5C".force_encoding('ascii-8bit')
|
||||||
header << [astc_list[fmt], astc_list[fmt], 1].pack("C*")
|
header << [astc_list[fmt], astc_list[fmt], 1].pack('C*')
|
||||||
header << [width].pack("V").byteslice(0, 3)
|
header << [width].pack('V').byteslice(0, 3)
|
||||||
header << [height].pack("V").byteslice(0, 3)
|
header << [height].pack('V').byteslice(0, 3)
|
||||||
header << "\x01\x00\x00"
|
header << "\x01\x00\x00"
|
||||||
header + bin
|
header + bin
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -468,7 +470,7 @@ module Mikunyan
|
|||||||
when 0
|
when 0
|
||||||
(s ? -f : f) * 2.0**-24
|
(s ? -f : f) * 2.0**-24
|
||||||
else
|
else
|
||||||
(s ? -1 : 1) * (f / 1024.0 + 1) * (2.0 ** ((e >> 10)-15))
|
(s ? -1 : 1) * (f / 1024.0 + 1) * (2.0**((e >> 10) - 15))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
# Class for representing decoded object
|
# Class for representing decoded object
|
||||||
# @attr [String] name object name
|
# @attr [String] name object name
|
||||||
@@ -81,12 +83,12 @@ module Mikunyan
|
|||||||
# Return value of called key
|
# Return value of called key
|
||||||
# @param [String] name key
|
# @param [String] name key
|
||||||
# @return [Object] value
|
# @return [Object] value
|
||||||
def method_missing(name, *args)
|
def method_missing(name, *_args)
|
||||||
@attr[name.to_s]
|
@attr[name.to_s]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Implementation of respond_to_missing?
|
# Implementation of respond_to_missing?
|
||||||
def respond_to_missing?(symbol, include_private)
|
def respond_to_missing?(symbol, _include_private)
|
||||||
@attr.key?(symbol.to_s)
|
@attr.key?(symbol.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
# Class for representing TypeTree
|
# Class for representing TypeTree
|
||||||
# @attr [Array<Mikunyan::TypeTree::Node>] nodes list of all nodes
|
# @attr [Array<Mikunyan::TypeTree::Node>] nodes list of all nodes
|
||||||
@@ -27,15 +29,15 @@ module Mikunyan
|
|||||||
end
|
end
|
||||||
buffer = br.read(buffer_size)
|
buffer = br.read(buffer_size)
|
||||||
nodes.each do |n|
|
nodes.each do |n|
|
||||||
if n.type >= 0
|
n.type = if n.type >= 0
|
||||||
n.type = buffer.unpack("@#{n.type}Z*")[0]
|
buffer.unpack1("@#{n.type}Z*")
|
||||||
else
|
else
|
||||||
n.type = Mikunyan::STRING_TABLE[n.type + 2**31]
|
Mikunyan::STRING_TABLE[n.type + 2**31]
|
||||||
end
|
end
|
||||||
if n.name >= 0
|
n.name = if n.name >= 0
|
||||||
n.name = buffer.unpack("@#{n.name}Z*")[0]
|
buffer.unpack1("@#{n.name}Z*")
|
||||||
else
|
else
|
||||||
n.name = Mikunyan::STRING_TABLE[n.name + 2**31]
|
Mikunyan::STRING_TABLE[n.name + 2**31]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
r = TypeTree.new
|
r = TypeTree.new
|
||||||
@@ -49,7 +51,7 @@ module Mikunyan
|
|||||||
def self.load_legacy(br)
|
def self.load_legacy(br)
|
||||||
nodes = []
|
nodes = []
|
||||||
stack = [0]
|
stack = [0]
|
||||||
while stack.size > 0
|
until stack.empty?
|
||||||
depth = stack.pop
|
depth = stack.pop
|
||||||
type = br.cstr
|
type = br.cstr
|
||||||
name = br.cstr
|
name = br.cstr
|
||||||
@@ -59,7 +61,7 @@ module Mikunyan
|
|||||||
version = br.i32u
|
version = br.i32u
|
||||||
flags = br.i32u
|
flags = br.i32u
|
||||||
child_count = br.i32u
|
child_count = br.i32u
|
||||||
child_count.times{ stack << depth + 1 }
|
child_count.times{stack << depth + 1}
|
||||||
nodes << Node.new(version, depth, is_array, type, name, size, index, flags)
|
nodes << Node.new(version, depth, is_array, type, name, size, index, flags)
|
||||||
end
|
end
|
||||||
r = TypeTree.new
|
r = TypeTree.new
|
||||||
@@ -71,7 +73,7 @@ module Mikunyan
|
|||||||
# @param [String] hash
|
# @param [String] hash
|
||||||
# @return [Mikunyan::TypeTree,nil] created TypeTree
|
# @return [Mikunyan::TypeTree,nil] created TypeTree
|
||||||
def self.load_default(hash)
|
def self.load_default(hash)
|
||||||
hash_str = hash.unpack('H*')[0]
|
hash_str = hash.unpack1('H*')
|
||||||
file = File.expand_path("../typetrees/#{hash_str}.dat", __FILE__)
|
file = File.expand_path("../typetrees/#{hash_str}.dat", __FILE__)
|
||||||
return nil unless File.file?(file)
|
return nil unless File.file?(file)
|
||||||
r = TypeTree.new
|
r = TypeTree.new
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Mikunyan
|
module Mikunyan
|
||||||
# version string
|
# version string
|
||||||
VERSION = "3.9.6"
|
VERSION = '3.9.6'
|
||||||
end
|
end
|
||||||
|
|||||||
+18
-17
@@ -1,31 +1,32 @@
|
|||||||
# coding: utf-8
|
# frozen_string_literal: true
|
||||||
lib = File.expand_path("../lib", __FILE__)
|
|
||||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
lib = File.expand_path('lib', __dir__)
|
||||||
require "mikunyan/version"
|
$:.unshift(lib) unless $:.include?(lib)
|
||||||
|
require 'mikunyan/version'
|
||||||
|
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = "mikunyan"
|
spec.name = 'mikunyan'
|
||||||
spec.version = Mikunyan::VERSION
|
spec.version = Mikunyan::VERSION
|
||||||
spec.authors = ["Ishotihadus"]
|
spec.authors = ['Ishotihadus']
|
||||||
spec.email = ["hanachan.pao@gmail.com"]
|
spec.email = ['hanachan.pao@gmail.com']
|
||||||
|
|
||||||
spec.summary = "Unity asset deserializer for Ruby"
|
spec.summary = 'Unity asset deserializer for Ruby'
|
||||||
spec.description = "Library to deserialize Unity assetbundles and assets."
|
spec.description = 'Library to deserialize Unity assetbundles and assets.'
|
||||||
spec.homepage = "https://github.com/Ishotihadus/mikunyan"
|
spec.homepage = 'https://github.com/Ishotihadus/mikunyan'
|
||||||
spec.license = "MIT"
|
spec.license = 'MIT'
|
||||||
|
|
||||||
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
||||||
f.match(%r{^(test|spec|features)/})
|
f.match(%r{^(test|spec|features)/})
|
||||||
end
|
end
|
||||||
spec.bindir = "exe"
|
spec.bindir = 'exe'
|
||||||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
spec.executables = spec.files.grep(%r{^exe/}){|f| File.basename(f)}
|
||||||
spec.require_paths = ["lib"]
|
spec.require_paths = ['lib']
|
||||||
spec.extensions = ["ext/decoders/native/extconf.rb"]
|
spec.extensions = ['ext/decoders/native/extconf.rb']
|
||||||
|
|
||||||
spec.add_dependency 'extlz4', '~> 0'
|
|
||||||
spec.add_dependency 'extlzma', '~> 0'
|
|
||||||
spec.add_dependency 'bin_utils', '~> 0'
|
spec.add_dependency 'bin_utils', '~> 0'
|
||||||
spec.add_dependency 'chunky_png', '~> 1'
|
spec.add_dependency 'chunky_png', '~> 1'
|
||||||
|
spec.add_dependency 'extlz4', '~> 0'
|
||||||
|
spec.add_dependency 'extlzma', '~> 0'
|
||||||
spec.add_dependency 'json', '~> 2'
|
spec.add_dependency 'json', '~> 2'
|
||||||
|
|
||||||
spec.add_development_dependency 'bundler', '~> 1'
|
spec.add_development_dependency 'bundler', '~> 1'
|
||||||
|
|||||||
Reference in New Issue
Block a user