DynamicBuffer<T>
An array-like data structure that can be used as a component.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Struct
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
- Implements: IQueryTypeParameter, IEnumerable<T>, IEnumerable, INativeList<T>, IIndexable<T>
public struct DynamicBuffer<T> : IQueryTypeParameter, IEnumerable<T>, IEnumerable, INativeList<T>, IIndexable<T> where T : unmanaged
Properties
Property | Description |
|---|---|
| Capacity | The number of elements the buffer can hold. |
| IsCreated | Whether the memory for this dynamic buffer has been allocated. |
| IsEmpty | Reports whether container is empty. |
| this[] | Array-like indexing operator. |
| Length | The number of elements the buffer holds. |
Methods
Method | Description |
|---|---|
| Add | Adds an element to the end of the buffer, resizing as necessary. |
| AddRange | Adds all the elements from |
| AsNativeArray | Return a native array that aliases the original buffer contents. |
| Clear | Sets the buffer length to zero. |
| CopyFrom | Copies all the elements from an array. |
| ElementAt | Gets the reference to the element at the given index. |
| EnsureCapacity | Ensures that the buffer has at least the specified capacity. |
| GetEnumerator | Provides an enumerator for iterating over the buffer elements. |
| GetUnsafePtr | Gets an |
| GetUnsafeReadOnlyPtr | Gets an |
| Insert | Inserts an element at the specified index, resizing as necessary. |
| Reinterpret | Returns a dynamic buffer of a different type, pointing to the same buffer memory. |
| RemoveAt | Removes the element at the specified index. |
| RemoveAtSwapBack | Removes the element at the specified index and swaps the last element into its place. This is more efficient than moving all elements following the removed element, but does change the order of elements in the buffer. |
| RemoveRange | Removes the specified number of elements, starting with the element at the specified index. |
| RemoveRangeSwapBack | Removes the specified number of elements, starting with the element at the specified index. It replaces the elements that were removed with a range of elements from the back of the buffer. This is more efficient than moving all elements following the removed elements, but does change the order of elements in the buffer. |
| Resize | Sets the length of this buffer, increasing the capacity if necessary. |
| ResizeUninitialized | Sets the length of this buffer, increasing the capacity if necessary. |
| ToNativeArray | Copies the buffer into a new native array. |
| TrimExcess | Removes any excess capacity in the buffer. |