Search Unity

Preview 21 issues

Discussion in 'Entity Component System' started by Tazadar66, Dec 5, 2018.

  1. Tazadar66

    Tazadar66

    Joined:
    Aug 27, 2013
    Posts:
    57
    Hello I dont know how to replaces these calls :

    entityManager.GetComponentDataFromEntity and entityManager.GetBufferFromEntity

    I have these errors :

    Assets/Scripts/Grid/Bootstraps/GridBootstrap.cs(178,89): error CS1061: 'EntityManager' does not contain a definition for 'GetComponentDataFromEntity' and no accessible extension method 'GetComponentDataFromEntity' accepting a first argument of type 'EntityManager' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Grid/Bootstraps/GridBootstrap.cs(195,88): error CS1061: 'EntityManager' does not contain a definition for 'GetBufferFromEntity' and no accessible extension method 'GetBufferFromEntity' accepting a first argument of type 'EntityManager' could be found (are you missing a using directive or an assembly reference?)

    Thanks :)
     
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    You have to let your system know when you want to use CDFE because system collects who read and write data. It is now have to be requested from inside ComponentSystem's code. (protected method)

    I don't know why GetBufferFromEntity is missing, but [Inject] BufferFromEntity inside the system code works. (as well as inject CDFE)
     
  3. BanJaxe

    BanJaxe

    Joined:
    Nov 20, 2017
    Posts:
    47
    ComponentSystem only has this.GetComponentDataFromEntity
    JobComponentSystem additionally has this.GetBufferFromEntity

    Not sure if there's a reason for that or just a missing feature for now.
     
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I just added [Inject] BufferFromEntity<T> in ComponentSystem and can confirm that it works. Maybe just a mistake?
     
  5. BanJaxe

    BanJaxe

    Joined:
    Nov 20, 2017
    Posts:
    47
    I meant the public methods in the base classes, not using injection.

    JobComponentSystem inherits from ComponentSystemBase and adds:

    public BufferFromEntity<T> GetBufferFromEntity<T>(bool isReadOnly = false) where T : struct, IBufferElementData;
     
  6. Tazadar66

    Tazadar66

    Joined:
    Aug 27, 2013
    Posts:
    57
    Thanks for your help but my problem is that I need to use EntityManager from a bootstrap script and I don't have any access to these two methods now :(
     
  7. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    If you can get a hold of EntityManager in your bootstrap script then just create a manager right there and call into its public method/update to do things.