Search Unity

Question Does the valid entity change its index and version during runtime?

Discussion in 'Entity Component System' started by Michelle_Ca, Jan 6, 2023.

  1. Michelle_Ca

    Michelle_Ca

    Joined:
    Aug 19, 2019
    Posts:
    113
    I'm trying to store some references of entities, after instantiating them inside a list in a monobehaviour script, and for safety i'm wondering in what cases can the index and version of the valid entity change during the runtime?
     
  2. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    639
    It’s an identifier. If the entity remains valid, the identifier remains valid and doesn’t change (why would it?)
     
    Michelle_Ca and Antypodish like this.
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    To add on top of the enswer, index and version are only allocated, when new entity is created. Not during its life span.
    Released indexes can be recycled and reused, from destroyed entities.
    Version will always increment, when using recycled index.
    So in any normal circumstances, there is no way to having entities identifier conflict of index+version.
     
    Spy-Master and Michelle_Ca like this.
  4. Michelle_Ca

    Michelle_Ca

    Joined:
    Aug 19, 2019
    Posts:
    113
    Thank you very much :)