Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsComposer.Operation

A composer operation.
Read time 1 minuteLast updated 13 days ago

Definition

public enum PhysicsComposer.Operation

Remarks

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.

Examples

// 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(); }}

Fields

Value

Description

ANDPerform an AND operation (geometric intersection).
NOTPerform a NOT operation (geometric difference).
ORPerform an OR operation (geometric merge).
XORPerform an XOR operation (geometric flip).