Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

BlobBuilder

struct in Unity.Entities

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Creates blob assets.

A blob asset is an immutable data structure stored in unmanaged memory. Blob assets can contain primitive types, strings, structs, arrays, and arrays of arrays. Arrays and structs must only contain blittable types. Strings must be of type BlobString (or a specialized unmanaged string type).

To use a BlobBuilder object to create a blob asset: 1. Declare the structure of the blob asset as a struct. 2. Create a BlobBuilder object. 3. Call the BlobBuilder.ConstructRoot method, where T is the struct defining the asset structure. 4. Initialize primitive values defined at the root level of the asset. 5. Allocate memory for arrays, structs, and BlobString instances at the root. 6. Initialize the values of those arrays, structs, and strings. 7. Continue allocating memory and initializing values until you have fully constructed the asset. 8. Call BlobBuilder.CreateBlobAssetReference to create a reference to the blob asset in memory. 9. Dispose the BlobBuilder object.

Use the BlobAssetReference<T0> returned by BlobBuilder.CreateBlobAssetReference to reference the blob asset. You can use a BlobAssetReference<T0> as a field of an IComponentData struct. More than one entity can reference the same blob asset.

Call BlobAssetReference<T0>.Dispose to free the memory allocated for a blob asset.

Blob assets cannot be modified once created. Instead, you must create a new blob asset, update any references to the old one and then dispose of it.

Properties

Property Description
IsCreated Returns true if this BlobBuilder has been allocated.

Constructors

Constructor Description
BlobBuilder Constructs a BlobBuilder object.

Public Methods

Method Description
Allocate Allocates enough memory to store length elements of struct T.
Construct Copies an array of structs to an array in a blob asset after allocating the necessary memory.
ConstructRoot Creates the top-level fields of a single blob asset.
CreateBlobAssetReference Completes construction of the blob asset and returns a reference to the asset in unmanaged memory.
Dispose Disposes of this BlobBuilder instance and frees its temporary memory allocations.
SetPointer Sets a BlobPtr to point to the given object inside the blob.