Just print out name string, not the entire Name struct (#8494)
# Objective This is just an oversight on my part when I implemented this in https://github.com/bevyengine/bevy/pull/7186, there isn't much reason to print out the hash of a `Name` like it does currently: ``` Name { hash: 1608798714325729304, name: "Suzanne" } (7v0) ``` ## Solution Instead it would be better if we just printed out the string like so: ``` "Suzanne" (7v0) ``` As it conveys all of the information in a less cluttered and immediately intuitive way which was the original purpose of `DebugName`. Which I also think translates to `Name` as well since I mostly see it as a thin wrapper around a string. --------- Co-authored-by: Carter Anderson <mcanders1@gmail.com>
This commit is contained in:
parent
8ec4b99a69
commit
c324b90ffe
@ -17,8 +17,8 @@ use std::{
|
|||||||
/// [`Name`] should not be treated as a globally unique identifier for entities,
|
/// [`Name`] should not be treated as a globally unique identifier for entities,
|
||||||
/// as multiple entities can have the same name. [`bevy_ecs::entity::Entity`] should be
|
/// as multiple entities can have the same name. [`bevy_ecs::entity::Entity`] should be
|
||||||
/// used instead as the default unique identifier.
|
/// used instead as the default unique identifier.
|
||||||
#[derive(Reflect, FromReflect, Component, Debug, Clone)]
|
#[derive(Reflect, FromReflect, Component, Clone)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct Name {
|
pub struct Name {
|
||||||
hash: u64, // TODO: Shouldn't be serialized
|
hash: u64, // TODO: Shouldn't be serialized
|
||||||
name: Cow<'static, str>,
|
name: Cow<'static, str>,
|
||||||
@ -79,6 +79,13 @@ impl std::fmt::Display for Name {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Name {
|
||||||
|
#[inline(always)]
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
std::fmt::Debug::fmt(&self.name, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Convenient query for giving a human friendly name to an entity.
|
/// Convenient query for giving a human friendly name to an entity.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
Loading…
Reference in New Issue
Block a user