public void Create(TapeGrid tapeGrid) { this.tapeGrid = tapeGrid; var gridrt = grid.GetComponent <RectTransform>().rect; primitiveSize = (gridrt.width - (tapeGrid.width - 1) * primitiveMargin) / tapeGrid.width; grid.cellSize = new Vector2(primitiveSize, primitiveSize); grid.constraintCount = tapeGrid.width; var primitivesPerHeight = (int)(gridrt.height / primitiveSize) + 2; newRowIndex = tapeGrid.height - primitivesPerHeight - 2; for (var i = newRowIndex + 1; i < tapeGrid.height; i++) { CreateNewRow(i); } paintLock = false; }
public void Create(TapeGrid tapeGrid) { this.tapeGrid = tapeGrid; var gridrt = grid.GetComponent <RectTransform>().rect; primitiveSize = (gridrt.width - (tapeGrid.width - 1) * primitiveMargin) / tapeGrid.width; grid.cellSize = new Vector2(primitiveSize, primitiveSize); grid.constraintCount = tapeGrid.width; var rowsPerScreen = (int)(gridrt.height / primitiveSize); if (rowsPerScreen * primitiveSize < gridrt.height) { rowsPerScreen++; } rowsToRender = tapeGrid.height < rowsPerScreen + 1 ? tapeGrid.height : rowsPerScreen + 1; // First -1 to convert to zero numerated index from length, // another -1 to select row that is above row that is seen screenRowsShift = tapeGrid.height - rowsToRender; rowToRenderIndex = screenRowsShift == 0 ? tapeGrid.height - 1 : screenRowsShift; for (var i = 0; i < rowsToRender; i++) { CreateNewRow(i + screenRowsShift); } paintLock = false; rowsMoved = 0; }