Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Dynamic Buffers as Chunk Components

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by Kmsxkuse, Dec 8, 2022.

  1. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    305
    Has there been any work done to support dynamic buffers on chunk components?
     
  2. Brian_Will

    Brian_Will

    Unity Technologies

    Joined:
    Apr 4, 2020
    Posts:
    13
    It's now possible to put collections in an IComponentData, including chunk components, so you should be able to put a NativeList in your chunk component for pretty much the same effect as a DynamicBuffer.

    Honestly, chunk components are a very niche feature, so it's surprising to hear such a request. What is your use case?
     
    Kmsxkuse likes this.
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,222
    How would you know when to dispose such a container?

    A use case I ran into is wanting to keep a separate culling LOD state cache for each culling pass InstanceID.
     
    Kmsxkuse likes this.
  4. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    305
    I would use the buffer as the sum total of the buffers on entities within the chunk but a NativeArray inside a chunk component does the same.

    Timing the disposal when all entities within the chunk get removed is annoying though. A chunk buffer would simplify it significantly.
     
  5. Brian_Will

    Brian_Will

    Unity Technologies

    Joined:
    Apr 4, 2020
    Posts:
    13
    Yeah, lifetime is problematic. Also I was reminded of an important limitation: collections in components cannot be used in jobs (and it's not clear if this limitation might be lifted in later versions).
     
    Kmsxkuse likes this.
  6. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    305
    Oh, that's unfortunate. Since the DB I am using are all fixed sizes, I've been prototyping a chunk component that has a fixed field reinterpreted to the struct that populates the dynamic buffers of entities within the chunk.

    It might waste a bit of space in the chunk but hopefully not too much.