Construct type_name
from ComponentId
#5104
Labels
A-Diagnostics
Logging, crash handling, error reporting and performance analysis
A-ECS
Entities, components, systems, and events
A-Reflection
Runtime information about types
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
When attempting to debug and display error messages for
ComponentId
-related code, we can only report the rawComponentId(usize)
to the users. This is not very helpful for debugging purposes.What solution would you like?
init_component::<T>
, store the type name inComponents
.Components::type_name(component_id: ComponentId) -> Option<String>
method.What alternative(s) have you considered?
a) Store the type name as part of
ComponentId
. This would be extremely convenient, but increases the size of a struct in the hot path of the ECS.b) Provide a method to get an
Option<TypeId>
from aComponentId
, then convert that into a type name. Unfortunately, Rust does not provide any tools for the second part of this step: type names can only be constructed from values and types.Additional context
#1481 needs this to significantly improve error reporting.
The text was updated successfully, but these errors were encountered: