AssetsTools.NET
AssetsTools.NET copied to clipboard
Incorrectly decoding textures
Hello! I'm trying to export some textures from an AssetBundle file using AssetsTools.NET.Texture
and SixLabors.ImageSharp
, but it produces incorrect texture (I also got the correct one using random asset browser program).
Code (minimal reproduction):
using AssetsTools.NET.Extra;
using AssetsTools.NET.Texture;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
var manager = new AssetsManager("commonassets.ab");
var bundle = manager.LoadBundleFile(path);
var assetFile = manager.LoadAssetsFileFromBundle(bundle, "CAB-580061e156ea5e60815bbe6b768da65c");
var asset = assetFile.file.GetAssetInfo(-9143244479974055439);
var field = manager.GetBaseField(assetFile, asset);
var texture = TextureFile.ReadTextureFile(field);
var bgraRaw = texture.GetTextureData(null, bundle.file);
var image = Image.LoadPixelData<Bgra32>(bgraRaw, texture.m_Width, texture.m_Height);
image.SaveAsPng($"texture.png");