Version: 2020.2

BoundsInt.allPositionsWithin

切换到手册
public BoundsInt.PositionEnumerator allPositionsWithin ;

描述

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

Positions within the BoundsInt are not inclusive of the positions on the upper limits of the BoundsInt. This iterator will only return positions of size greater than zero for each axis.

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