Version: 2022.1
言語: 日本語
public void DeleteShape (int shapeIndex);

パラメーター

shapeIndex The index of the shape stored the PhysicsShapeGroup2D.

説明

When destroying a shape at the specified shapeIndex, all other shapes that exist above the specified shapeIndex will have their shape indices updated appropriately.

using UnityEngine;
using UnityEngine.Assertions;

public class Example : MonoBehaviour { void Start() { // Create a shape group. var shapeGroup = new PhysicsShapeGroup2D();

// Add two Circles to the shape group. shapeGroup.AddCircle ( center: Vector2.left, radius: 1f ); var shapeIndex = shapeGroup.AddCircle ( center: Vector2.right, radius: 1f );

// Add a Box to the shape group. shapeGroup.AddBox ( center: new Vector2(3f, 2f), size: new Vector2(1f, 1f) );

// Validate the contents. Assert.AreEqual(1 + 1 + 1, shapeGroup.shapeCount); Assert.AreEqual(1 + 1 + 4, shapeGroup.vertexCount); Assert.AreEqual(PhysicsShapeType2D.Circle, shapeGroup.GetShape(0).shapeType); Assert.AreEqual(PhysicsShapeType2D.Circle, shapeGroup.GetShape(1).shapeType); Assert.AreEqual(PhysicsShapeType2D.Polygon, shapeGroup.GetShape(2).shapeType);

// Delete the second Circle shape. shapeGroup.DeleteShape(shapeIndex);

// Validate the contents. Assert.AreEqual(1 + 1, shapeGroup.shapeCount); Assert.AreEqual(1 + 4, shapeGroup.vertexCount); Assert.AreEqual(PhysicsShapeType2D.Circle, shapeGroup.GetShape(0).shapeType); Assert.AreEqual(PhysicsShapeType2D.Polygon, shapeGroup.GetShape(1).shapeType); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961