diff --git a/Experimental/Unity/ArcUnityFS.cs b/Experimental/Unity/ArcUnityFS.cs index 08d9541c..f76d2d0d 100644 --- a/Experimental/Unity/ArcUnityFS.cs +++ b/Experimental/Unity/ArcUnityFS.cs @@ -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 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 (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; diff --git a/Experimental/Unity/Asset.cs b/Experimental/Unity/Asset.cs index c7a0a103..268ffd39 100644 --- a/Experimental/Unity/Asset.cs +++ b/Experimental/Unity/Asset.cs @@ -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 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(); - 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