example types fixes
This commit is contained in:
parent
2958700eb2
commit
2433fd6435
@ -6,11 +6,11 @@ To run the example, use the provided `Makefile` with `make run` or run manually
|
||||
```sh
|
||||
BEVY_REFLECT_AUTO_REGISTER_STATIC=1 cargo run --features bevy/reflect_auto_register_static
|
||||
```
|
||||
This approach should generally work on all platforms, however it is less convenient and a slows down linking and it's recommended to use it only as a fallback.
|
||||
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:
|
||||
1. `load_type_registrations!` macro must be called before constructing `App` or using `TypeRegistry::register_derived_types`.
|
||||
2. 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 separate `lib` and `bin` setup.
|
||||
3. Registration function names are cached in `target/type_registrations`. Due to incremental compilation the only way to rebuild this cache is to build without `bevy/reflect_auto_register_static` (or `auto_register_static` if just using `bevy_reflect`) feature enabled and then rebuild again with this feature and `BEVY_REFLECT_AUTO_REGISTER_STATIC=1` environment variable set. Running `cargo clean` before recompiling is also an option, but it is even slower to do.
|
||||
3. Registration function names are cached in `target/type_registrations`. Due to incremental compilation the only way to rebuild this cache is to build with `bevy/reflect_auto_register_static` (or `auto_register_static` if just using `bevy_reflect`) feature disabled, then delete `target/type_registrations` and rebuild again with this feature enabled and `BEVY_REFLECT_AUTO_REGISTER_STATIC=1` environment variable set. Running `cargo clean` before recompiling is also an option, but it is even slower to do.
|
||||
|
||||
If you're experiencing linking issues try running `cargo clean` before rebuilding.
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
// The type that should be automatically registered.
|
||||
// All types subject to automatic registration must be defined in `lib`,
|
||||
// any `#[derive(Reflect)]` registration without the `bin` are not guaranteed to be registered automatically.
|
||||
// All types subject to automatic registration must be defined not be define in the same crate as `load_type_registrations!``.
|
||||
// Any `#[derive(Reflect)]` types within the `bin` crate are not guaranteed to be registered automatically.
|
||||
#[derive(Reflect)]
|
||||
struct Struct {
|
||||
a: i32,
|
||||
@ -32,7 +32,7 @@ pub fn main() {
|
||||
fn startup(reg: Res<AppTypeRegistry>) {
|
||||
let registry = reg.read();
|
||||
info!(
|
||||
"Is `Struct` get registered? {}",
|
||||
"Is `Struct` registered? {}",
|
||||
registry.contains(core::any::TypeId::of::<Struct>())
|
||||
);
|
||||
info!(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user