Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetCallbackTarget(ReadOnlySpan<PhysicsBody>, object)

Set the same Object that event callbacks will be sent to on a batch of bodies. Each body is assigned the callback target as PhysicsBody.callbackTarget would, and setting it to NULL removes it.
Read time 1 minuteLast updated a day ago

Definition

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

SetCallbackTarget(ReadOnlySpan<PhysicsBody>, Object)

public static int SetCallbackTarget(ReadOnlySpan<PhysicsBody> bodies, object callbackTarget)

Parameters

The bodies to set the callback target on.

callbackTarget

The callback target to set on every body, or NULL to remove it.

Returns

Type

Description

intThe number of bodies that were ignored (not set because the body was invalid). A single warning is logged when any are ignored.

Remarks

This is faster than setting PhysicsBody.callbackTarget on each body.