Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question how to get rid of "Prefab" entities when i still need them?

Discussion in 'Entity Component System' started by Salmakis, Dec 7, 2022.

  1. Salmakis

    Salmakis

    Joined:
    May 14, 2018
    Posts:
    15
    When i have prefab like entities, that identifications i store in a singleton IComponent to be used with Instantiate from entitycommandbuffer or entitymanager, how can i then achieve that it is not ben used by queries?

    should i ad a disable component, and when i want to instatiate with it then remove the disable and then add it agan?
    or should we at all prefer to use the archetypes instead of that entity prefabs?

    or is there just some small trick that i just not see? =)
     
  2. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    There is a Prefab component that you can put into your prefab entities.
    Entities with the Prefab component are excluded from entity queries automatically, similar to the Disabled component.
    When instantiating an entity with a Prefab component the Prefab component gets removed automatically.
     
    Salmakis likes this.
  3. Salmakis

    Salmakis

    Joined:
    May 14, 2018
    Posts:
    15
    oh woow! that is helpfull. thank you