Search code examples
c++entt

How can I access all entities in an entt::registry?


I'm trying to use entt by following an old tutorial. The following piece of code was working then, but the current version I am using now does not have the entt::registry::each method. Is there another way I can implement the code below?

m_context->m_registry.each([&](auto entityID)
    {
        entity ent{ entityID , m_context.get() };
        // something
    });

Solution

  • Try it like this:

    for(auto entity: registry.view<entt::entity>()) 
    {
        // ...
    }
    

    (https://github.com/skypjack/entt/wiki/Crash-Course:-entity-component-system)