Commit d196050
Allow using short type names for asset processors. (#21339)
# Objective
- Previously, asset processors needed to be **fully specified**. This
meant writing met files by hand was incredibly cumbersome.
- In addition, using `core::any::type_name` is generally undesirable
since it is only intended for debugging.
## Solution
- Require `TypePath` impl on `AssetLoader`, `AssetTransformer`,
`AssetSaver`, and `AssetProcessor`.
- Register loaders and processors by their `TypePath::type_path`. This
makes the path format stable.
- Additionally register the processors by their
`TypePath::short_type_path`, and ensure there are no other processors
with the same `short_type_path`. If a user tries to use an ambiguous
short type path, we list out all full type paths.
Note: I left doing this with asset loaders as a future PR. There's more
complexity there (since we have to deal with pre-registering asset
loaders), and this seems like the bigger "bang for our buck".
## Testing
- I ran the asset_processing example. No change.
- I changed the asset processing example to use the short type path. It
still behaved as expected.
- I created a new AssetTransformer in
`asset_processing::sneaky::CoolTextTransformer` and a new processor that
looked identical to the regular one (but using the sneaky transformer).
It printed an error, listing out the full paths of both processors!
---------
Co-authored-by: Carter Anderson <[email protected]>1 parent f991d79 commit d196050
File tree
27 files changed
+487
-85
lines changed- crates
- bevy_animation/src
- bevy_asset/src
- processor
- server
- bevy_audio/src
- bevy_gltf/src/loader
- bevy_image/src
- bevy_pbr/src/meshlet
- bevy_scene/src
- bevy_shader/src
- bevy_text/src
- examples/asset
- processing
- assets
- release-content
- migration-guides
- release-notes
27 files changed
+487
-85
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
769 | 769 | | |
770 | 770 | | |
771 | 771 | | |
772 | | - | |
| 772 | + | |
773 | 773 | | |
774 | 774 | | |
775 | 775 | | |
| |||
1934 | 1934 | | |
1935 | 1935 | | |
1936 | 1936 | | |
| 1937 | + | |
1937 | 1938 | | |
1938 | 1939 | | |
1939 | 1940 | | |
| |||
1986 | 1987 | | |
1987 | 1988 | | |
1988 | 1989 | | |
| 1990 | + | |
1989 | 1991 | | |
1990 | 1992 | | |
1991 | 1993 | | |
| |||
2040 | 2042 | | |
2041 | 2043 | | |
2042 | 2044 | | |
| 2045 | + | |
2043 | 2046 | | |
2044 | 2047 | | |
2045 | 2048 | | |
| |||
2103 | 2106 | | |
2104 | 2107 | | |
2105 | 2108 | | |
| 2109 | + | |
| 2110 | + | |
2106 | 2111 | | |
2107 | 2112 | | |
2108 | 2113 | | |
| |||
2186 | 2191 | | |
2187 | 2192 | | |
2188 | 2193 | | |
| 2194 | + | |
2189 | 2195 | | |
2190 | 2196 | | |
2191 | 2197 | | |
| |||
2270 | 2276 | | |
2271 | 2277 | | |
2272 | 2278 | | |
| 2279 | + | |
| 2280 | + | |
2273 | 2281 | | |
2274 | 2282 | | |
2275 | 2283 | | |
| |||
2531 | 2539 | | |
2532 | 2540 | | |
2533 | 2541 | | |
| 2542 | + | |
2534 | 2543 | | |
2535 | 2544 | | |
2536 | 2545 | | |
| |||
2834 | 2843 | | |
2835 | 2844 | | |
2836 | 2845 | | |
| 2846 | + | |
2837 | 2847 | | |
2838 | 2848 | | |
2839 | 2849 | | |
| |||
2912 | 2922 | | |
2913 | 2923 | | |
2914 | 2924 | | |
| 2925 | + | |
2915 | 2926 | | |
2916 | 2927 | | |
2917 | 2928 | | |
| |||
2952 | 2963 | | |
2953 | 2964 | | |
2954 | 2965 | | |
| 2966 | + | |
2955 | 2967 | | |
2956 | 2968 | | |
2957 | 2969 | | |
| |||
3030 | 3042 | | |
3031 | 3043 | | |
3032 | 3044 | | |
| 3045 | + | |
3033 | 3046 | | |
3034 | 3047 | | |
3035 | 3048 | | |
| |||
3057 | 3070 | | |
3058 | 3071 | | |
3059 | 3072 | | |
| 3073 | + | |
3060 | 3074 | | |
3061 | 3075 | | |
3062 | 3076 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
70 | | - | |
| 70 | + | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
120 | | - | |
| 120 | + | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
0 commit comments