Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

Operation

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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

Properties

Property Description
OR Perform an OR operation (geometric merge).
AND Perform an AND operation (geometric intersection).
NOT Perform a NOT operation (geometric difference).
XOR Perform an XOR operation (geometric flip).