Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CreateShapeBatch

Create a batch of Circle shapes attached to the specified body.
Read time 8 minutesLast updated 13 days ago

Definition

  • Type: Method
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule

CreateShapeBatch(PhysicsBody, ReadOnlySpan<CircleGeometry>, PhysicsShapeDefinition, Allocator)

Create a batch of Circle shapes attached to the specified body.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<CircleGeometry> geometry, PhysicsShapeDefinition definition, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

CreateShapeBatch(PhysicsBody, ReadOnlySpan<CircleGeometry>, PhysicsShapeDefinition, Object, int, Allocator)

Create a batch of Circle shapes attached to the specified body, assigning the given owner to every created shape.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<CircleGeometry> geometry, PhysicsShapeDefinition definition, Object owner, int ownerKey, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

owner

The owner object to assign to every created shape. If null, no owner is assigned.

ownerKey

The owner key to assign. Must be non-zero when owner is not null. See PhysicsWorld.CreateOwnerKey.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

Remarks

CreateShapeBatch(PhysicsBody, ReadOnlySpan<PolygonGeometry>, PhysicsShapeDefinition, Allocator)

Create a batch of Polygon shapes attached to the specified body.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<PolygonGeometry> geometry, PhysicsShapeDefinition definition, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

CreateShapeBatch(PhysicsBody, ReadOnlySpan<PolygonGeometry>, PhysicsShapeDefinition, Object, int, Allocator)

Create a batch of Polygon shapes attached to the specified body, assigning the given owner to every created shape.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<PolygonGeometry> geometry, PhysicsShapeDefinition definition, Object owner, int ownerKey, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

owner

The owner object to assign to every created shape. If null, no owner is assigned.

ownerKey

The owner key to assign. Must be non-zero when owner is not null. See PhysicsWorld.CreateOwnerKey.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

Remarks

CreateShapeBatch(PhysicsBody, ReadOnlySpan<CapsuleGeometry>, PhysicsShapeDefinition, Allocator)

Create a batch of Capsule shapes attached to the specified body.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<CapsuleGeometry> geometry, PhysicsShapeDefinition definition, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

CreateShapeBatch(PhysicsBody, ReadOnlySpan<CapsuleGeometry>, PhysicsShapeDefinition, Object, int, Allocator)

Create a batch of Capsule shapes attached to the specified body, assigning the given owner to every created shape.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<CapsuleGeometry> geometry, PhysicsShapeDefinition definition, Object owner, int ownerKey, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

owner

The owner object to assign to every created shape. If null, no owner is assigned.

ownerKey

The owner key to assign. Must be non-zero when owner is not null. See PhysicsWorld.CreateOwnerKey.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

Remarks

CreateShapeBatch(PhysicsBody, ReadOnlySpan<SegmentGeometry>, PhysicsShapeDefinition, Allocator)

Create a batch of Segment shapes attached to the specified body.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<SegmentGeometry> geometry, PhysicsShapeDefinition definition, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

CreateShapeBatch(PhysicsBody, ReadOnlySpan<SegmentGeometry>, PhysicsShapeDefinition, Object, int, Allocator)

Create a batch of Segment shapes attached to the specified body, assigning the given owner to every created shape.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<SegmentGeometry> geometry, PhysicsShapeDefinition definition, Object owner, int ownerKey, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

owner

The owner object to assign to every created shape. If null, no owner is assigned.

ownerKey

The owner key to assign. Must be non-zero when owner is not null. See PhysicsWorld.CreateOwnerKey.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

Remarks

CreateShapeBatch(PhysicsBody, ReadOnlySpan<ChainSegmentGeometry>, PhysicsShapeDefinition, Allocator)

Create a batch of Chain Segment shapes attached to the specified body.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<ChainSegmentGeometry> geometry, PhysicsShapeDefinition definition, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

CreateShapeBatch(PhysicsBody, ReadOnlySpan<ChainSegmentGeometry>, PhysicsShapeDefinition, Object, int, Allocator)

Create a batch of Chain Segment shapes attached to the specified body, assigning the given owner to every created shape.
public static NativeArray<PhysicsShape> CreateShapeBatch(PhysicsBody body, ReadOnlySpan<ChainSegmentGeometry> geometry, PhysicsShapeDefinition definition, Object owner, int ownerKey, Allocator allocator = Allocator.Temp)

Parameters

The body to attach the shape to.

The shape geometry to use.

The shape definition to use.

owner

The owner object to assign to every created shape. If null, no owner is assigned.

ownerKey

The owner key to assign. Must be non-zero when owner is not null. See PhysicsWorld.CreateOwnerKey.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

NativeArray<PhysicsShape>The created shapes. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.

Remarks