Make asset loading no longer use the type of the load. - #25664
Conversation
|
Why shouldn't it be allowed to load an extension as different types? For example, a custom asset loader could load a png as a custom type different from |
|
@beicause loading an extension as multiple different types breaks a lot of things. For example if you are loading several types from the ron extension, untyped loads are entirely broken, since we don't know which ron loader to use. The migration guide already has two alternative ways to fix this. Here's a third, specifically for Ron loaders (or other containers like JSON). Instead of having one RON loader per type, you just have one ungeneric RonLoader, which returns a The point is there are workarounds, and that we end up making the asset loader totally unambiguous. That fixes untyped loads, editor workflows, asset processing, and more. Relying on guessing the correct loader based on how you load it falls apart whenever you're not loading it yourself, and I think it's a good thing to make the assets on disk "self-describing". |
Objective
Fix a bunch of weird edge cases of asset loading:
asset_server.load<Gltf>("whatever.png"), this will try to use theGltfLoadersince we prioritize the asset type not the extension.asset_server.load<Image>("whatever.png")andasset_server.load<Gltf>("whatever.png"), this will actually do two loads, even though one of these loads makes no sense!Solution
I haven't fixed all of the above issues, but this is the first step.
Testing