版本: Unity 6 (6000.0)
语言英语
  • C#

BoundsInt.allPositionsWithin

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交,但我们会阅读用户提出的每项更改建议,并在必要时进行更新。

关闭

提交失败

由于某种原因,您的更改建议无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

public BoundsInt.PositionEnumerator allPositionsWithin;

描述

包含 BoundsInt 内所有位置的 BoundsInt.PositionCollection。

BoundsInt 内的位置不包含 BoundsInt 上限上的位置。此迭代器只会返回每个轴大小大于零的位置。

using UnityEngine;

public class ExampleScript : MonoBehaviour { // Create a BoundsInt of a cube with a // bottom-left coordinate of (0, 0, 0), // and a height, width and depth of 4, // and log its contained points to the console. void Start() { // bounds is a cube where every edge has exactly four points. // It has 4 * 4 * 4 = 64 points. // min = (0,0,0), max = (3,3,3). var bounds = new BoundsInt(new Vector3Int(0, 0, 0), new Vector3Int(4, 4, 4));

// Iterate through each point, and log it to the Debug Console. foreach (var point in bounds.allPositionsWithin) { Debug.Log(point.ToString()); }

// The 64 unique integer 3-dimensional points that fall within this Bounds will be logged to the Debug Console. } }