jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.15k stars 169 forks source link

Identifying entities by their component marker #71

Closed shmelrad closed 1 year ago

shmelrad commented 2 years ago

I know that it is possible to add a Name component to an entity. But I had an idea: if an entity has one component marker, then in the inspector, instead of the Entity, insert the name of this component. Most likely, it is impossible to do this in Rust (Rast is not a dynamic programming language), and if possible, I think it will be quite slow (most likely you will have to iterate through all the components of each entity), but I am not so experienced to confidently state this. But suddenly it's possible :)

jakobhellermann commented 2 years ago

Something like this is already hardcoded for a bunch of common component combinations: https://github.com/jakobhellermann/bevy-inspector-egui/blob/36d7b23922c1298f7280a8ceeac88088bcca45b9/src/world_inspector/mod.rs#L617

The problem is that it not really possible to tell which component should be representative for the entity. For a simple heuristic like component_size == 0 a bunch of entities will be named e.g. RayCastMesh which isn't really helpful.

jakobhellermann commented 1 year ago

I'm gonna close this. We guess based on some heuristics, and if people want to suggest other heuristics they can open a new issue.