mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
e3fb23d4d3
Fixes #1895 Changed most `println` to `info` in examples, some to `warn` when it was useful to differentiate from other more noisy logs. Added doc on `LogPlugin`, how to configure it, and why (and how) you may need to disable it
26 lines
755 B
Rust
26 lines
755 B
Rust
use bevy::{prelude::*, reflect::TypeRegistry};
|
|
use std::any::TypeId;
|
|
|
|
/// You must manually register each instance of a generic type
|
|
fn main() {
|
|
App::build()
|
|
.add_plugins(DefaultPlugins)
|
|
.register_type::<MyType<u32>>()
|
|
.add_startup_system(setup.system())
|
|
.run();
|
|
}
|
|
|
|
#[derive(Reflect)]
|
|
struct MyType<T: Reflect> {
|
|
value: T,
|
|
}
|
|
|
|
fn setup(type_registry: Res<TypeRegistry>) {
|
|
let type_registry = type_registry.read();
|
|
|
|
let registration = type_registry.get(TypeId::of::<MyType<u32>>()).unwrap();
|
|
info!("Registration for {} exists", registration.short_name());
|
|
|
|
// MyType<String> was not manually registered, so it does not exist
|
|
assert!(type_registry.get(TypeId::of::<MyType<String>>()).is_none());
|
|
}
|