Version: 2022.2

Physics2D.OverlapCapsuleNonAlloc

切换到手册
public static int OverlapCapsuleNonAlloc (Vector2 point, Vector2 size, CapsuleDirection2D direction, float angle, Collider2D[] results, int layerMask= DefaultRaycastLayers, float minDepth= -Mathf.Infinity, float maxDepth= Mathf.Infinity);

参数

point 胶囊体的中心。
size 胶囊体的大小。
direction 胶囊体的方向。
angle 胶囊体的角度。
results 用于接收结果的数组。
layerMask 筛选器,用于检查仅在指定层上的对象。
minDepth 仅包括 Z 坐标(深度)大于该值的对象。
maxDepth 仅包括 Z 坐标(深度)小于该值的对象。

返回

int 返回放置在 results 数组中的结果数。

描述

Get a list of all Colliders that fall within a capsule area. Note: This method will be deprecated in a future build and it is recommended to use OverlapCapsule instead.

此函数类似于 OverlapCapsuleAll,不同之处在于其结果会返回到提供的数组中。整数返回值是位于该胶囊体内的对象数(可能为零),但如果结果数组中没有足够的元素来报告所有这些结果,则不会调整该数组的大小。其意义在于不为这些结果分配内存,因此,如果经常进行检查,可以提高垃圾回收性能。

另请参阅:OverlapCapsuleOverlapCapsuleAll

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