forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
49 lines (44 loc) · 1.41 KB
/
lib.rs
File metadata and controls
49 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Demonstrates how to set up automatic reflect types registration for platforms without `inventory` support
use bevy::prelude::*;
// The type that should be automatically registered.
// All types subject to automatic registration must not be defined 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,
}
mod private {
mod very_private {
use bevy::prelude::*;
// Works with private types too!
#[allow(
clippy::allow_attributes,
dead_code,
reason = "This struct is used as a compilation test to test the derive macros, and as such is intentionally never constructed."
)]
#[derive(Reflect)]
struct PrivateStruct {
a: i32,
}
}
}
/// This is the main entrypoint, bin just forwards to it.
pub fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, startup)
.run();
}
fn startup(reg: Res<AppTypeRegistry>) {
let registry = reg.read();
info!(
"Is `Struct` registered? {}",
registry.contains(core::any::TypeId::of::<Struct>())
);
info!(
"Type info of `PrivateStruct`: {:?}",
registry
.get_with_short_type_path("PrivateStruct")
.expect("Not registered")
);
}