PhysicsShapeGroup2D.SetShapeRadius
Declaration
public void SetShapeRadius(int shapeIndex, float radius);Параметры
| Параметр | Описание |
|---|---|
| shapeIndex | Индекс фигуры, хранящейся в PhysicsShapeGroup2D. Индекс фигуры основан на нуле с группой фигур, имеющей количество фигур, указанное shapeCount. |
| радиус | Значение радиуса фигуры. |
Описание
Задает радиус фигуры.
using UnityEngine; using UnityEngine.Assertions;
public class Example : MonoBehaviour { void Start() { // Create a shape group. var shapeGroup = new PhysicsShapeGroup2D();
// Add a Circle to the shape group. var shapeIndex = shapeGroup.AddCircle ( center: Vector2.zero, radius: 0.5f );
// Fetch the Circle shape and validate the radius. var physicsShape = shapeGroup.GetShape(shapeIndex); Assert.AreApproximatelyEqual(0.5f, physicsShape.radius);
// Update the Circle radius. shapeGroup.SetShapeRadius(shapeIndex, 2f);
// Fetch the Circle shape and validate the radius. physicsShape = shapeGroup.GetShape(shapeIndex); Assert.AreApproximatelyEqual(2f, physicsShape.radius); } }