Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetOwnerUserData

Set PhysicsUserData that can be used for any purpose, typically by the owner only.
Read time 1 minuteLast updated 12 days ago

Definition

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

SetOwnerUserData(PhysicsUserData, int)

Set PhysicsUserData that can be used for any purpose, typically by the owner only.
public void SetOwnerUserData(PhysicsUserData physicsUserData, int ownerKey = 0)

Parameters

physicsUserData

The user data to set.

ownerKey

Optional owner key returned when using PhysicsBody.SetOwner.

SetOwnerUserData(ReadOnlySpan<PhysicsBody>, ReadOnlySpan<PhysicsUserData>, int)

Set PhysicsUserData on a batch of bodies that can be used for any purpose, typically by the owner only. The bodies and userDatas spans must be the same length; bodies[n] receives userDatas[n].
public static void SetOwnerUserData(ReadOnlySpan<PhysicsBody> bodies, ReadOnlySpan<PhysicsUserData> userDatas, int ownerKey = 0)

Parameters

The bodies to set the owner user data on.

The user data to set, one entry per body.

ownerKey

Optional owner key returned when using PhysicsBody.SetOwner.

SetOwnerUserData(ReadOnlySpan<PhysicsBody>, PhysicsUserData, int)

Set the same PhysicsUserData on a batch of bodies that can be used for any purpose, typically by the owner only.
public static void SetOwnerUserData(ReadOnlySpan<PhysicsBody> bodies, PhysicsUserData physicsUserData, int ownerKey = 0)

Parameters

The bodies to set the owner user data on.

physicsUserData

The user data to set on every body.

ownerKey

Optional owner key returned when using PhysicsBody.SetOwner.