public void AdjustPixelPositionTest() { Point cellSize = new Point(32); Point gridSize = new Point(30); for (int x = -gridSize.X; x < gridSize.X; x++) { for (int y = -gridSize.Y; y < gridSize.Y; y++) { for (int subX = 0; subX < cellSize.X; subX++) { for (int subY = 0; subY < cellSize.Y; subY++) { Assert.AreEqual(new Point(x, y) * cellSize, GridLayoutHelper.SnapPixelPosition((new Point(x, y) * cellSize) + new Point(subX, subY), cellSize)); } } } } }
public override void OnCreated() { cellLayout = GetComponent <GridLayout>(); mouseHandler = GetComponent <MouseHandler>(); // // TODO: CORRECT THIS WITH SPACING. // // If both components were given, bind left click to select a cell. if (mouseHandler != null && cellLayout != null) { mouseHandler.LeftClicked.Connect(() => { if (Enabled) { cellLeftClicked.Invoke(GridLayoutHelper.PixelToCellPosition(mouseHandler.RelativeMousePosition, cellLayout.CellSize)); } }); mouseHandler.RightClicked.Connect(() => { if (Enabled) { cellRightClicked.Invoke(GridLayoutHelper.PixelToCellPosition(mouseHandler.RelativeMousePosition, cellLayout.CellSize)); } }); } }