nesrak1 / AssetsTools.NET

Read and write unity assets/bundle files, based on https://github.com/SeriousCache/UABE
MIT License
537 stars 101 forks source link

Trying to read asset bundle #136

Open gonsodany opened 1 month ago

gonsodany commented 1 month ago

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 commented 1 month ago

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

nesrak1 commented 1 month ago

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

gonsodany commented 1 month ago

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