Attach custom data to 2D Physics Core objects
Attach values and physics masks to physics objects so you can fetch them later.
Read time 1 minuteLast updated 14 days ago
To attach custom data to a 2D Physics Core component, use the User Data section of the window.
Inspector
?
Follow these steps:
- Select a GameObject with any 2D Physics Core component.
- In the Inspector window, expand the User Data section.
- Set a value for one of the custom properties. For example, set Int to 42 to attach the integer value of 42 to the component.
To fetch the data in the API, get the property of the physics object. For example:
userDataDebug.Log(myShape.userData.intValue);