コード例 #1
0
    public static void SetOriginSquare()
    {
        //get the grid coordinates of the box (see GetBoxCoordinates in documentation); we get three coordinates, but we only use X and Y
        //we add 0.1f * Vector3.one to avoid unexpected behaviour for edge cases dues to rounding and float (in)accuracy
        Vector3 box = _grid.useCustomRenderRange ? _grid.GetBoxCoordinates(_grid.transform.position + _grid.renderFrom + 0.1f * Vector3.one) :
                      _grid.GetBoxCoordinates(_grid.transform.position - _grid.size + 0.1f * Vector3.one);

        originSquare = new int[2] {
            Mathf.RoundToInt(box.x), Mathf.RoundToInt(box.z)
        };
    }