AssetsTools.NET icon indicating copy to clipboard operation
AssetsTools.NET copied to clipboard

Trying to read asset bundle

Open gonsodany opened this issue 1 year ago • 3 comments

Im trying to modify an asset bundle, what im trying to do is modify some parameters on an animator controller of the asset bundle, i've been trying for 2 days to so much as read the asset bundle but nothing on the examples/documentation works

using the "Read Asset bundles" example but the code doesnt work

"var manager = new AssetsManager();

// Load the bundle file var bunInst = manager.LoadBundleFile(assetURL, true); foreach (var asset in bunInst.file.GetAllFileNames()) {

} var afileInst = manager.LoadAssetsFileFromBundle(bunInst, 0, false); var afile = afileInst.file;

// Loop through the textures and log their names and dimensions foreach (var texInfo in afile.GetAssetsOfType(AssetClassID.Texture2D)) { var texBase = manager.GetBaseField(afileInst, texInfo); var name = texBase["m_Name"].AsString; var width = texBase["m_Width"].AsInt; var height = texBase["m_Height"].AsInt;

Debug.Log($"Texture {name} is sized {width}x{height}");

}"

image image image these methods dont exist

gonsodany avatar Oct 09 '24 20:10 gonsodany

doing "var afileInst = manager.LoadAssetsFileFromBundle(bunInst, 0, false);" always just gives me the error "ArgumentNullException: Value cannot be null. Parameter name: path2 System.IO.Path.Combine (System.String path1, System.String path2) (at <27124aa0e30a41659b903b822b959bc7>:0) AssetsTools.NET.Extra.AssetsManager.LoadAssetsFileFromBundle (AssetsTools.NET.Extra.BundleFileInstance bunInst, System.Int32 index, System.Boolean loadDeps) (at C:/Users/nesquack/Documents/GitReposLocal/AssetsTools.NET/AssetTools.NET/Extra/AssetsManager/AssetsManager.cs:170)" too

gonsodany avatar Oct 09 '24 21:10 gonsodany

Where did you get AssetsTools.NET from? The github releases page is out of date, so you should get it from nuget if you didn't already. The method you said is missing is there: https://github.com/nesrak1/AssetsTools.NET/blob/2207c788da2dc9198fb1a91ed67b212f1c1cad2d/AssetTools.NET/Standard/AssetsBundleFileFormat/AssetBundleFile.cs#L772

nesrak1 avatar Oct 10 '24 00:10 nesrak1

I got it from github, which would make sense the missing/outdated methods

gonsodany avatar Oct 10 '24 05:10 gonsodany