Search Unity

(API Question) Accessing a DynamicBuffer on a per entity basis.

Discussion in 'Entity Component System' started by Mr-Mechanical, Nov 16, 2018.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I'm trying to access a DynamicBuffer attached to an entity.
    https://github.com/Unity-Technologi...24/Documentation/reference/dynamic_buffers.md

    I'm looking at the docs but I can't get GetBufferArrayFromEntity or GetBufferFromEntity replacement to work in a job. How should I use it?

    I would consider [Inject], but I'm scared of using injection because I heard from somewhere that it's going to be eventually depreciated.
     
    B0dg3 likes this.
  2. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    I think there may currently be a restriction on accessing BufferArrayFromEntity<T> and BufferFromEntity<T> outside of an IJob. It may work if it's [ReadOnly] access to the struct but I'm not sure. Going to look into this for something I'm working on tonight/tomorrow, so I'll report back once I get specifics.

    Edit: May apply to both types.
     
    Last edited: Nov 16, 2018
    Mr-Mechanical likes this.