Clarifying BlobAssetReference

With the example below im creating the BlobAssetRef once and adding to multiple components. This is just adding the pointer to the components and not copying the data each time , correct ?

public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
    // ONE Builder
    var BuildMyDataBlobAssetRef = BuildMtData(gameObject);

    // Adding BlobAssetRef to multiple components
    dstManager.AddComponentData(entity, new MyComponentA
    {
        BuildMyDataBlobAssetRef = buildMyDataBlobAssetRef
    });

    dstManager.AddComponentData(entity, new MyComponentB
    {
        BuildMyDataBlobAssetRef = buildMyDataBlobAssetRef
    });

    dstManager.AddComponentData(entity, new MyComponentC
    {
        BuildMyDataBlobAssetRefA = buildMyDataBlobAssetRef,
        BuildMyDataBlobAssetRefB = buildMyDataBlobAssetRef
    });
}

private BlobAssetReference<MyData> BuildMtData(GameObject gameObject)
{
    using (var builder = new BlobBuilder(Allocator.Temp))
    {
        ref MyData root = ref builder.ConstructRoot<MyData>();
        var array = builder.Allocate(ref root.myData, 100);
       
        //
        // ... Fill array
       
        return builder.CreateBlobAssetReference<MyData>(Allocator.Persistent);
    }
}

Correct

1 Like

Thank you