Skip to content

Move an asset's MetaTransform into its AssetInfo. - #25509

Open
andriyDev wants to merge 2 commits into
bevyengine:mainfrom
andriyDev:meta-transform-in-info
Open

Move an asset's MetaTransform into its AssetInfo.#25509
andriyDev wants to merge 2 commits into
bevyengine:mainfrom
andriyDev:meta-transform-in-info

Conversation

@andriyDev

Copy link
Copy Markdown
Contributor

Objective

  • Previously, the MetaTransform of an asset (sort-of like its settings) lived on the Handle of an asset. This can lead to weird situations that don't make sense like some handles for an asset reporting a meta transform while others don't, or loading an asset with settings, which then get erased on a reload later on.

Solution

  • Move the MetaTransform into the AssetInfo. This is the canonical location of info about the asset, and it is centralized.

This makes it easier to create handles for an asset, since now you only need the path + type ID, and you don't have to be confused about the meta transform. I don't think this makes it any harder to solve #11111, since we'll need to store the meta transform somewhere on the AssetInfos to be able to reload them, and it feels weird to need to upgrade a handle just to fetch its meta transform.

Note that accessing the meta transform isn't particularly informative. In order to get anything useful out of it, you'd need to know what loader it's targeting, then apply the meta transform, and then read the mutated settings. Very confusing! If we are to solve #11111, we need something more interpretable other than a function (since we can't diff a function).

Testing

  • Unit tests pass.

@andriyDev

Copy link
Copy Markdown
Contributor Author

This is based off of #25506. I'll rebase it once that's merged.

@andriyDev
andriyDev requested a review from greeble-dev August 22, 2026 05:22
@andriyDev andriyDev added A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 22, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Assets Aug 22, 2026
@andriyDev
andriyDev force-pushed the meta-transform-in-info branch from 7ad17a7 to 50631c2 Compare August 22, 2026 05:23

@greeble-dev greeble-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor suggestions. Will review again once rebased.

Comment on lines +52 to +56
// Manual Debug impl since MetaTransform is not Debug.
impl core::fmt::Debug for AssetInfo {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("AssetInfo")
.field("weak_handle", &self.weak_handle)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to make MetaTransform a newtype with a Debug implementation that prints something like "[closure]"? Not a big deal though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, I personally don't care about this, and I think new typing this everywhere isn't very useful since it's not a public type anyway - it's just an implementation detail.

Comment thread crates/bevy_asset/src/server/info.rs
@andriyDev
andriyDev force-pushed the meta-transform-in-info branch from 50631c2 to e9d26cf Compare August 26, 2026 05:36
@andriyDev
andriyDev requested a review from greeble-dev August 26, 2026 05:36
@greeble-dev greeble-dev added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

3 participants