文档

Unity Engine

Unity Engine

SetUserData

Set PhysicsUserData on a batch of joints that can be used for any purpose. The joints and userDatas spans must be the same length; joints[n] receives userDatas[n].
阅读时间1 分钟最后更新于 1 个月前

Definition

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

SetUserData(ReadOnlySpan<PhysicsJoint>, ReadOnlySpan<PhysicsUserData>)

Set PhysicsUserData on a batch of joints that can be used for any purpose. The joints and userDatas spans must be the same length; joints[n] receives userDatas[n].
public static int SetUserData(ReadOnlySpan<PhysicsJoint> joints, ReadOnlySpan<PhysicsUserData> userDatas)

Parameters

The joints to set the user data on.

The user data to set, one entry per joint.

Returns

Type

Description

intThe number of joints that were ignored (not set because the joint was invalid). A single warning is logged when any are ignored. If the spans are different lengths, nothing is set and every joint is counted as ignored.

SetUserData(ReadOnlySpan<PhysicsJoint>, PhysicsUserData)

Set the same PhysicsUserData on a batch of joints that can be used for any purpose.
public static int SetUserData(ReadOnlySpan<PhysicsJoint> joints, PhysicsUserData physicsUserData)

Parameters

The joints to set the user data on.

physicsUserData

The user data to set on every joint.

Returns

Type

Description

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