[Reflection] Getting struct field names and types without a world or entity #5403
-
I'm looking into ways to edit a scene in a graphical space and currently considering two options:
One thing that's necessary to Blender approach is to get a list of all components, the names of their fields and their types. I would very much like to ask the game for this information with a command line argument rather than manually create JSON blobs whenever I create a component. I poked around and experimented with the Reflection module a little bit and found it very easy to a get a list of all the components. What was more challenging was getting the names and types of component fields. The only way I was able to accomplish this was to create a World and an entity, add components to that entity and then use the ReflectComponent to get the more detailed type data. Is there a way to get field name and types from the TypeRegistry without instantiating a world and an entity that has the components on it? If not, is there a way to say "Make an entity and add one of every component on it"? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Bevy version |
Beta Was this translation helpful? Give feedback.
Bevy version
0.8
introduces theTypeInfo
struct, which is exactly what you need. It allows you to get a type's field list and info without access to an instance.0.8
is right around the corner. So I'd say hang in there!