A composer operation.
Pass an operation into PhysicsComposer.AddLayer to control how each new layer combines with the layers already added to the PhysicsComposer.
OR adds the shape, AND keeps only the areas where the new shape and the existing shapes overlap, NOT subtracts the new shape from the existing shapes, and XOR removes overlapping areas but keeps the non-overlapping areas.
// Add a circle layer, then subtract a capsule layer from it. using UnityEngine; using Unity.Collections; using Unity.U2D.Physics;
public class ComposerOperationExample : MonoBehaviour { public CircleGeometry circleGeometry = CircleGeometry.defaultGeometry; public CapsuleGeometry capsuleGeometry = CapsuleGeometry.defaultGeometry;
void Start() { PhysicsComposer composer = PhysicsComposer.Create(Allocator.Temp); composer.AddLayer(circleGeometry, PhysicsTransform.identity, PhysicsComposer.Operation.OR); composer.AddLayer(capsuleGeometry, PhysicsTransform.identity, PhysicsComposer.Operation.NOT);
// Destroy the composer to also destroy the temporary allocator. composer.Destroy(); } }