Jump to content

No prefabs in .ksp assetbundle


Recommended Posts

Trying to create a U4.6 UI for B9PW, I can't get the prefabs out of the asset bundle I'm loading.

The bundle loader is here, the bundle xml is here. Everything has definitely been copied into the ksp testing directory

Relevant log entries on hitting the main menu do not log any objects

[LOG 07:46:33.316] [B9PW] Aquiring bundle data
[LOG 07:46:33.379] [UIApp] Adding MessageSystem to Application Launcher
[LOG 07:46:33.382] [ApplicationLauncher] SetHidden: 
[LOG 07:46:33.384] [B9PW] unloading bundle

I can't for the life of me work out what I'm not doing

Link to comment
Share on other sites

There are a couple potential problems

  1. The URL should be escaped
  2. The bundle might have failed to load (check WWW.error, might have failed due to 1)
  3. The docs don't mention it for WWW.LoadFromCacheOrDownload method so this might not apply, but in the constructor for WWW, filenames under windows should be prefixed with file:/// rather than file://
Link to comment
Share on other sites

1/3)It has no issues finding the shader in that bundle using this version so file location is not an issue. It's only the prefabs (things of type GameObject) that it wont load
2) www.error is null

Whats really irritating is that I have the exact same piece of code (with a different address) working for a single prefab in different mod

I'm thinking it has to be something about using multiple objects/types in a bundle or I've got a setting wrong while building the bundle...

Edited by Crzyrndm
Link to comment
Share on other sites

No, I understand what's going on now. The code is working as expected and is loading the cached version which was probably made before the bundle had any prefabs in it. I think you'll find that anything you add from this point on will appear not to work unless you Caching.CleanCache() or increment the asset bundle version number in LoadFromCacheOrDownload. Why cache it at all? The bundle is already stored locally so this will just double disk usage

 

Link to comment
Share on other sites

Version increment worked (:D), caching.clearcache doesn't.

As for the method, it was originally copied from the IR github when I had issues with the KSP asset loader. I couldn't get the Unity Assetloader example to work and that one did, so I never really stopped to think about it at the time

Edited by Crzyrndm
Link to comment
Share on other sites

7 hours ago, Crzyrndm said:

or it's just not allowing more than 1 object to load from each AssetBundle. Do I really have to put each prefab in a seperate bundle...

No you don't - you just have to load via www.LoadFromCacheOrDownload rather than the original B9PW loader you had ( I borrowed it & immediately found it failed loading more than one asset ). Having said all that, the game is already preloading .ksp bundles so I do wonder why we're doing all this anyway...

Edited by Van Disaster
Link to comment
Share on other sites

The stock loader works fine AFAIK but you should not use it in the loading screen (the main menu does something to bundles a few seconds after loading is seems). I needed to use the custom one because I wanted to load my UI at game launch and not have to wait for the bundles load.

Link to comment
Share on other sites

Actually that was me having a derp moment - it's the stock one that won't retrieve more than the first asset in a bundle, rather than some random method X. I wonder if we're doing something wrong building multi-asset bundles.

Edited by Van Disaster
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...