Version: 2022.3
言語: 日本語
public void SetShapeRadius (int shapeIndex, float radius);

パラメーター

shapeIndex The index of the shape stored in the PhysicsShapeGroup2D. The shape index is zero-based with the shape group having a quantity of shapes specified by shapeCount.
radius The value to set the shape radius to.

説明

Sets the radius of a shape.

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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961