Path: blob/main/examples/reflection/auto_register_static/README.md
9324 views
Automatic registration example for platforms without inventory support
This example illustrates how to use automatic type registration of bevy_reflect on platforms that don't support inventory.
To run the example, use the provided Makefile with make run or run manually by setting env var and enabling the required feature:
This approach should generally work on all platforms, however it is less convenient and slows down linking. It's recommended to use it only as a fallback.
Here's a list of caveats of this approach:
load_type_registrations!macro must be called before constructingAppor usingTypeRegistry::register_derived_types.All of the types to be automatically registered must be declared in a separate from
load_type_registrations!crate. This is why this example uses separatelibandbinsetup.Registration function names are cached in
target/type_registrations. Due to incremental compilation the only way to rebuild this cache is to build withbevy/reflect_auto_register_static(orauto_register_staticif just usingbevy_reflect) feature disabled, then deletetarget/type_registrationsand rebuild again with this feature enabled andBEVY_REFLECT_AUTO_REGISTER_STATIC=1environment variable set. Runningcargo cleanbefore recompiling is also an option, but it is even slower to do.
If you're experiencing linking issues try running cargo clean before rebuilding.