private BlockPlacementPermission PreviewPlacement(out Vector3Int coordinateToPlace) { coordinateToPlace = Vector3Int.zero; if (UIHelper.IsMouseOverUI()) { return(BlockPlacementPermission.OutOfRange); } Ray ray = activeCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 100f, layerMask)) { Stub stub = hit.transform.GetComponent <Stub>(); if (stub == null) { return(BlockPlacementPermission.OutOfRange); } //Debug.Log("hit stub: " + stub.name); //g.transform.position = hit.point; coordinateToPlace = stub.BlockCoordinate + Vector3Int.up; BlockPlacementPermission canPlace = WorldGrid.CanPlace(previewBlock, coordinateToPlace); //Debug.Log("try : " + coordinateToPlace + ": " + canPlace.ToString(), stub); while (canPlace == BlockPlacementPermission.Occupied) { coordinateToPlace += Vector3Int.up; //Debug.Log("try : " + coordinateToPlace, stub); canPlace = WorldGrid.CanPlace(previewBlock, coordinateToPlace); } if (canPlace == BlockPlacementPermission.Valid) { //Debug.Log("can : " + coordinateToPlace, stub); Vector3 previewPosition = WorldGrid.CoordinateToWorldPosition(coordinateToPlace); previewBlock.transform.position = previewPosition; } return(canPlace); } return(BlockPlacementPermission.OutOfRange); }