Search Unity

Why ISharedComponentData can store Mesh/Material class variables

Discussion in 'Entity Component System' started by 5argon, Jun 15, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I see in examples that you can store Mesh and Material inside ISharedComponentData. Both of them is not a struct but a class.

    - Is that only few exceptions, or any class reference works with ISharedCompoenentData?
    - If reference values are allowed, two ISharedComponentData struct are considered the same by comparing the class's reference address?
     
  2. zulfajuniadi

    zulfajuniadi

    Joined:
    Nov 18, 2017
    Posts:
    117
    Yes any ISharedComponentData can store ref values but there's no way at the moment to pass them into a job as jobs can't have non blittable properties. AddSharedComponentData / SetSharedComponentData should be done in the main thread.

    Right now I'm accessing those values via static properties which is considered hacky *gasp*.
     
    5argon likes this.
  3. Afonso-Lage

    Afonso-Lage

    Joined:
    Jul 8, 2012
    Posts:
    70
    I think
    ISharedComponentData
    allowing us to add reference to manage code is a workarround because Unity still lacks a lot of pure ECS systems, like the rendering one, which you still need Mesh and Materials classes.

    What makes me think that is the way they are writing ECS to give us performance by default, which includes using the so called HPC# subset and witch does not includes references, to avoid memory aliasing.
     
    Last edited: Jun 16, 2018
    5argon likes this.