Create a macro to replace the LoadTransformAndSave generic type.#24012
Open
andriyDev wants to merge 5 commits into
Open
Create a macro to replace the LoadTransformAndSave generic type.#24012andriyDev wants to merge 5 commits into
LoadTransformAndSave generic type.#24012andriyDev wants to merge 5 commits into
Conversation
88fadf9 to
9d5388d
Compare
Diddykonga
approved these changes
Apr 28, 2026
Contributor
There was a problem hiding this comment.
LGTM
The contextual names will be nice, only thing to worry about is potential code dupe with overlapping processor abstractions, although I dont know how often that will happen in practice.
Normally not a fan of macros, except in two situations:
- copy-pasta, when the impl is almost always the same, to get rid of repetition.
- syntax/semantics support not provided by rust, bsn is a great example.
This falls cleanly into 1.
Contributor
|
I don't know that I like this. My gut reaction is that this is more confusing than just repeating the verbose bits. What I think we should actually do is not require you to register LoadTransformAndSave<L, T, S> directly, but instead register each of those individual parts, and then Bevy should be automatically able to compose them when LoadTransformAndSave<L, T, S> is specified in the meta file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
LoadTransformAndSaveprocessors, you need to repeat the very long type usually twice. This type is also repeated within meta files (Makewrite_default_meta_file_for_pathwrite the short type path instead of the long type path. #22208 and Allow using short type names for asset processors. #21339 made this shorter, but it's still long). It also makes the meta files have not very descriptive names.Solution
LoadTransformAndSaveis the asset processor API, and so users concluded the processing API is much more limited than it is. I think a macro that generates a new type will hopefully give the vibe that it's just a type and there's something more fundamental going on.LoadTransformAndSave.Relying on a macro is a little gross, but that's the price of relying on type paths to identify items. The previous state highly discouraged expanding on processors (e.g., with generics), because it meant the type path would only get gnarlier.
An alternative could be to allow users to define aliases to processors, but I'm not super keen on that solution, since now we need to disambiguate between long type paths, short type paths, and aliases.
Testing
Showcase
Now instead of:
You can instead write: