Search Unity

  1. How has 2019.2 and the beta been for you so far? Give us feedback in this thread.
    Dismiss Notice

Question about ISharedComponent indexes

Discussion in 'Data Oriented Technology Stack' started by Buretto, May 17, 2019.

  1. Buretto

    Buretto

    Joined:
    Mar 23, 2015
    Posts:
    26
    1. I noticed that when I create an entity with a new
    ISharedComponent
    (in an otherwise empty scene/world),
    EntityManager.GetAllUniqueSharedComponentData(List)
    returns with a length of 2; with index [1] containing the values of the new
    ISharedComponent
    I made, and index[0] with empty/default data.
    I couldn't find if this is supposed to happen, but am guessing yes; since the empty/default data that is filled with zeros still counts as its own unique values, so it will always be there by default.

    2. But if that is the case, then I have no idea what is going on here: In the same
    OnUpdate
    , after I call the
    GetAllUniqueSharedComponentData
    , I run a job and call
    chunk.GetSharedComponentIndex(type)
    and it returns an index of 3? And one frame later, in the
    OnUpdate
    the list returns length of 2 again, and the in the chunk the same thing happens and it gets an index of 3. I double checked that I'm calling both of these functions with the same
    ISharedComponentData
    type.

    How I understand it is
    GetSharedComponentIndex
    is supposed to return the index specific to the type specified. e.g. if there are 3 different chunks which are separated by having different values of the same
    ISharedComponentData
    type, and these are the only chunks containing this type, calling
    GetSharedComponentIndex
    on each of them would return indexes 0, 1, and 2.

    What happens in 1. makes sense, I just want to be double sure.. but what happens in 2. is completely puzzling to me.. maybe one can confirm my understanding?

    All help appreciated, thanks. :)
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,305
  3. Buretto

    Buretto

    Joined:
    Mar 23, 2015
    Posts:
    26
    Hi eizenhorn,
    Thank you for reminding me of this, I went and re-read it all and found the solution was to use:
    GetAllUniqueSharedComponentData(SCDList, indexList);

    I had misunderstood and assumed the
    GetAllUniqueSharedComponentData(SCDList)
    returned a list with matching indexes but since this isn't the case the key was to include the
    indexList
    parameter.
    Thanks again :)