Simple example request #1415
Unanswered
SevenGameMaker
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am just starting with ECS and am in need of some help please :
what i have working :
an editor style application, i can create and destroy entities dynamically.
I can also list all of the available components in the world (so can add them to entities in the editor on right click)
I can also list all of the components currently attached to the selected entity as a tree with nodes.
what i need to do next is, when a component is selected from the tree of entities and their components, i want to ImGui draw the component's member variables and be able to manipulate them using imGui controls.
in a perfect world I wont know the of the component, just the name and whatever meta data i can get from the entity.
what i am trying so far.....
define a component structure
struct myInfo { int Id; std::string Name; }
register the structure with flecs for reflection
getECS()->getWorld().component("myInfo")
.member("Id", offsetof(myInfo, Id));
.memberstd::string("Name", offsetof(myInfo, Name));
create an entity and add the component
flecs::entity e = m_World.entity(name);
e.add();
when the entity is displayed in the tree, it has the myInfo component listed in the tree also.
when the component text is selected, all I have available is the flecs::entity and the name of the component.
i want to get the component by name like getComponentByName(flecs::entity, std::string componentname) and then manipulate the Id and Name inside the myInfo component instance.
I assume it has to do with the meta data to access the myInfo data members but I have no idea how to get to that from either the entity or the getComponentByName() which i assume should return a type_id or such that then I can access the meta data with?
for example, if the entities component member is an int then display an int gui control, if it is a float the display a float gui control, etc...
if I can get this figured out then I can continue my learning. thank you in advance for any help!
Beta Was this translation helpful? Give feedback.
All reactions