Exemple #1
0
    private void SnapToGrid()
    {
        int gridSize = BoardSquare.GetGridSize();

        //Sets the new pos limited by the above lines, label is also divided by grid size
        //so that the coords are on a scale of 1 (e.g. 0,0 0,1 1,1)
        // NEW v2 - grid position is moved to BoardSquare and stored there in a Vector2, hence y
        // is featured twice, getGridPos().y is the vector3 z equivalent.
        transform.position = new Vector3(BoardSquare.GetGridPos().x *gridSize,
                                         0f, BoardSquare.GetGridPos().y *gridSize);
    }