#Issue with BlobAsset Construction and Array Lengths

1 messages · Page 1 of 1 (latest)

grizzled gazelle
#

I am trying to use Blob in my code and encountered an issue. Here is the problem I'm facing:

In my code, I have a struct called BlobNavNode which contains several fields, including BlobArray<int> Vertex, BlobArray<int> ConnectionIndex, and BlobArray<long> ConnectionCost. I am using the BlobBuilder to construct a BlobAsset containing an array of BlobNavNode structs.

However, when I inspect the constructed BlobAsset at runtime, I noticed that the lengths of the ConnectionCost, ConnectionIndex, and Vertex arrays within each BlobNavNode are all zero. This is unexpected because I specified the lengths for these arrays during construction.

Here is a snippet of my code:

// ...

var nodeBuilder = new BlobBuilder(Allocator.Temp);
ref var nodeData = ref nodeBuilder.ConstructRoot<BlobArray<BlobNavNode>>();
var nodeArrayBuilder = nodeBuilder.Allocate(ref nodeData, nodes.Count);

for (var index = 0; index < nodes.Count; index++)
{
var node = nodes[index];
ref var blobNode = ref nodeBuilder.ConstructRoot<BlobNavNode>();

// Set fields of blobNode...

nodeBuilder.Construct(ref blobNode.ConnectionCost, node.connectionCost);
nodeBuilder.Construct(ref blobNode.ConnectionIndex, node.connectionIndex);
nodeBuilder.Construct(ref blobNode.Vertex, node.vertex);

nodeArrayBuilder[index] = blobNode;

}

// ...

I'm not sure why the lengths of these arrays are not being set correctly. Any insights or suggestions on how to resolve this issue would be greatly appreciated.

Thank you!

flat crown
#

you seem to be constructing root multiple times

#

is that intended

grizzled gazelle