SetUserData
Set PhysicsUserData on a batch of shapes that can be used for any purpose. The shapes and userDatas spans must be the same length; shapes[n] receives userDatas[n].
Read time 1 minuteLast updated a day ago
Definition
- Type: Method
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
SetUserData(ReadOnlySpan<PhysicsShape>, ReadOnlySpan<PhysicsUserData>)
Set PhysicsUserData on a batch of shapes that can be used for any purpose. The shapes and userDatas spans must be the same length; shapes[n] receives userDatas[n].
public static int SetUserData(ReadOnlySpan<PhysicsShape> shapes, ReadOnlySpan<PhysicsUserData> userDatas)
Parameters
The shapes to set the user data on.
The user data to set, one entry per shape.
Returns
Type | Description |
|---|---|
| int | The number of shapes that were ignored (not set because the shape was invalid). A single warning is logged when any are ignored. If the spans are different lengths, nothing is set and every shape is counted as ignored. |
SetUserData(ReadOnlySpan<PhysicsShape>, PhysicsUserData)
Set the same PhysicsUserData on a batch of shapes that can be used for any purpose.
public static int SetUserData(ReadOnlySpan<PhysicsShape> shapes, PhysicsUserData physicsUserData)
Parameters
The shapes to set the user data on.
The user data to set on every shape.
Returns
Type | Description |
|---|---|
| int | The number of shapes that were ignored (not set because the shape was invalid). A single warning is logged when any are ignored. |