Hey there just having a issue i really can't figure whats wrong. Basicaly my game works fine in editor but not in build mode. It crashes when trying to read a BlobArray from a BlobAsset from a ChunkJob (Confirmed in the crash log).
This BlobAsset is constructed in a baker like so (simplified). There is only one prefab with this baker
// Bakes a polygon collider 2D
struct ColliderData{
BlobArray<float2> array;
...Other data
}
struct ColliderComponent : ISharedComponentData {
BlobAssetReference<ColliderData> collider;
}
using BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp);
ref var collider = ref blobBuilder.ConstructRoot<ColliderData>();
// setup collider data
var builderPolys = blobBuilder.Allocate(ref collider.array, lengthOfMyVertices);
// Use builderPolys to build the array ...
var blob = blobBuilder.CreateBlobAssetReference<ColliderData>(Allocator.Persistent);
AddBlobAsset(blob, out _);
AddSharedComponent(new ColliderComponent{ collider = blob });
The baker code works fine, the AddBlobAsset method should help maintain the blob asset alive for it to work on the build side.
On the chunk side, it accesses the shared component containing the blobasset, the code is not out of the ordinary
public unsafe partial struct MyChunkJob : IJobChunk{
public MyAspect.TypeHandle aspectHandle;
public SharedComponentTypeHandle<ColliderComponent> colliderHandle;
public void Execute(in ArchetypeChunk chunk, ... ){
var aspects = aspectHandle.Resolve(chunk);
ColliderComponent col = chunk.GetSharedComponent(colliderHandle);
// The first level works fine, i can access the ColliderData
ref ColliderData colliderData = ref col.collider.Value;
// The second level crashes whenever i access the array length/indices
var length = colliderData.array.Length;
// Use the length variable otherwise it is ellided ...
}
}
Are there anything left i should check that i didn't?