It unfortunately looks like this is currently by design.
Collider.cs:1417
public uint ForceUniqueBlobID;
// ID used to force a unique collider blob in entities.
// When a collider is manually created or cloned, the ID is set to ~ColliderConstants.k_SharedBlobID
// marking the collider as unique.
// When a collider is created during baking through the blob asset store, the ID is set to
// ColliderConstants.k_SharedBlobID in order to enable sharing of identical collider blobs among entities.
// The sharing is disabled by the baking systems through setting of this value to a unique value when the user
// requests unique collider blobs via the force unique authoring option.
Hi, also encounter this behavior when as part of baking I create my own collider for my character controller.
This is causing me head heck because there is apparently no way to get a shared collider except through the built in authoring components.
This cause my collider to be unique and for prefabs to had a Collider Blob Cleanup which waste memory and reduce chunk capacity.
Is there any plan to allow us to create non unique colliders from script ?
I can maybe clarify what is going on here, and ease your concerns.
In essence, if you run-time create collider blobs, they are unique by default because Unity Physics does not automatically take care of any sharing of the collider blobs between PhysicsCollider components (aka rigid bodies).
This doesn’t prevent you from implementing collider blob sharing yourself. So, if you want to yourself use the same run-time created collider blob in multiple PhysicsColliders though, you can do so without any issues. You just need to take care of manually managing their disposal correctly, which you have to do with run-time created blobs anyways.
For example, you could just create a NativeList of the run-time created blobs and dispose of them in the OnDestroy function in some ISystem or so.
I hope this clarifies this situation and makes it clear that there is no limitation here if you want to share run-time created collider blobs yourself for efficiency.