Pin properties in 2D Physics Core
Configure global 2D Physics Core settings
Attach custom data to 2D Physics Core objects
To attach custom data to a 2D Physics Core component, use the User Data section of the Inspector window.
Note: This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.
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 userData property of the physics object. For example:
Debug.Log(myShape.userData.intValue);
Additional resources
Pin properties in 2D Physics Core
Configure global 2D Physics Core settings
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。