返回介绍

Physics2D.OverlapPointNonAlloc 重叠点不分配

发布于 2019-12-18 15:38:17 字数 2692 浏览 1078 评论 0 收藏 0

JavaScript => static function OverlapPointNonAlloc(point: Vector2, results: Collider2D[], layerMask: int = DefaultRaycastLayers, minDepth: float = -Mathf.Infinity, maxDepth: float = Mathf.Infinity): int;
C# => static int OverlapPointNonAlloc(Vector2 point, Collider2D[] results, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity);

Parameters 参数

pointA point in world space.
一个世界空间中的点。
resultsArray to receive results.
接收结果的数组。
layerMaskFilter to detect Colliders only on certain layers.
只在某些层过滤检测碰撞器。
minDepthOnly include objects with a Z coordinate (depth) greater than this value.
只包括Z坐标(深度)大于这个值的对象。
maxDepthOnly include objects with a Z coordinate (depth) less than this value.
只包括Z坐标(深度)小于这个值的对象。

Returns 返回值

int The number of results returned.
int返回结果的数量。

Description 描述

Get a list of all colliders that overlap a point in space.
得到一个列表,里面是所有与世界中的点重叠的碰撞器。

This function is similar to OverlapPointAll except that the results are returned in the supplied array. The integer return value is the number of objects that overlap the point (possibly zero) but the results array will not be resized if it doesn't contain enough elements to report all the results. The significance of this is that no memory is allocated for the results and so garbage collection performance is improved when the check is performed frequently.
这个函数与OverlapPointAll函数很像,区别在于他把返回结果放到一个事先准备好的数组内。整形的返回值(可能为零)就是射线贯穿的对象的数量,但是结果数组将不会重新调整大小即使他没有足够的元素装下所有的结果(碰撞器)。他的意义在于整个过程中不会为结果重新分配内存,使垃圾回收的频率降低从而提高了性能。

See Also: OverlapPoint, OverlapPointAll.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文