mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-26 23:24:00 +08:00
(ReadAssetBundle): method moved to AssetDeserializer.
This commit is contained in:
parent
12c2690ae3
commit
403c769d49
@ -251,7 +251,7 @@ namespace GameRes.Formats.Unity
|
||||
var asset_bundle = asset.Objects.FirstOrDefault (x => x.TypeId == bundle_type_id);
|
||||
if (asset_bundle != null)
|
||||
{
|
||||
id_map = asset.ReadAssetBundle (file, asset_bundle);
|
||||
id_map = ReadAssetBundle (file, asset_bundle);
|
||||
}
|
||||
}
|
||||
if (null == id_map)
|
||||
@ -290,6 +290,35 @@ namespace GameRes.Formats.Unity
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<long, string> ReadAssetBundle (Stream input, UnityObject bundle)
|
||||
{
|
||||
using (var reader = bundle.Open (input))
|
||||
{
|
||||
var name = reader.ReadString(); // m_Name
|
||||
reader.Align();
|
||||
int count = reader.ReadInt32(); // m_PreloadTable
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
reader.ReadInt32(); // m_FileID
|
||||
reader.ReadInt64(); // m_PathID
|
||||
}
|
||||
count = reader.ReadInt32(); // m_Container
|
||||
var id_map = new Dictionary<long, string> (count+1);
|
||||
id_map[bundle.PathId] = name;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
name = reader.ReadString();
|
||||
reader.Align();
|
||||
reader.ReadInt32(); // preloadIndex
|
||||
reader.ReadInt32(); // preloadSize
|
||||
reader.ReadInt32(); // m_FileID
|
||||
long id = reader.ReadInt64();
|
||||
id_map[id] = name;
|
||||
}
|
||||
return id_map;
|
||||
}
|
||||
}
|
||||
|
||||
string GetObjectName (Stream input, UnityObject obj)
|
||||
{
|
||||
TypeTree type;
|
||||
|
@ -130,37 +130,6 @@ namespace GameRes.Formats.Unity
|
||||
throw new ApplicationException (string.Format ("Duplicate asset object {0} (PathId: {1})", obj, obj.PathId));
|
||||
m_objects[obj.PathId] = obj;
|
||||
}
|
||||
|
||||
public Dictionary<long, string> ReadAssetBundle (Stream input, UnityObject bundle)
|
||||
{
|
||||
using (var stream = new StreamRegion (input, bundle.Offset, bundle.Size, true))
|
||||
using (var reader = new AssetReader (stream, ""))
|
||||
{
|
||||
reader.SetupReaders (m_format, m_is_little_endian);
|
||||
var name = reader.ReadString(); // m_Name
|
||||
reader.Align();
|
||||
var id_map = new Dictionary<long, string>();
|
||||
id_map[bundle.PathId] = name;
|
||||
int count = reader.ReadInt32(); // m_PreloadTable
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
reader.ReadInt32(); // m_FileID
|
||||
reader.ReadInt64(); // m_PathID
|
||||
}
|
||||
count = reader.ReadInt32(); // m_Container
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
name = reader.ReadString();
|
||||
reader.Align();
|
||||
reader.ReadInt32(); // preloadIndex
|
||||
reader.ReadInt32(); // preloadSize
|
||||
reader.ReadInt32(); // m_FileID
|
||||
long id = reader.ReadInt64();
|
||||
id_map[id] = name;
|
||||
}
|
||||
return id_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class AssetRef
|
||||
|
Loading…
Reference in New Issue
Block a user