# How can I mass-duplicate or "paint" Unity objects?

Let's say I have a basic map with a single box on it.

I want to make many, many more of these cubes, so they can cover a large portion of the map, like this:

Each box needs to be exactly one unit away from the adjacent boxes, so there is no overlap.

My idea was to clone the first box so the entire blue map is covered, then manually delete some of them to make the path.

In other software, there are ways to clone/duplicate large numbers of objects so that they fill an area, or follow a certain set of transformations. I cannot figure out how to do this in Unity.

I have tried manually duplicating the box and setting its location (so I have two properly-positioned boxes), then selected both of those and duplicating (so I have four boxes total), duplicating those, etc, but as soon as I select multiple boxes, I can't type in a location without all the selected boxes going there (so if I type a y-location of 12, every single selected box will be crammed on top of each other on y=12).

## 2 Answers

It's not a perfect solution (I hope others can suggest general-purpose tools for this), but I usually do this with keyboard shortcuts:

• Ctrl + D to duplicate the currently selected objects
• select all of them
• Hold Ctrl and drag the translation handles to move them, snapping to 1-unit increments

So I start with one object, dupe-move it to get 2 one unit apart, then select both and dupe-move them to get 4 in a line, then select all 4 and dupe-move to get 8...

It's laborious, but progress gets faster with each doubling so it's a lot better than positioning them all one-by-one.

If I had to do this a lot (say, making a dozen or more levels built out of cubes like the one above) I'd probably write an editor script to mass-duplicate objects in a rectangular array, or paint them as you describe (or maybe populate them on level load by reading a bitmap image, so I can paint my levels in a drawing program... depends on the game).

I haven't fully grokked editor scripting though, so it always involves a little trial and error for me to get it right, which means I can't give concise instructions that I'm sure will work, so I'll leave discussion of that option to someone with more experience. ;)

I can't type in a location without all the selected boxes going there (so if I type a y-location of 12, every single selected box will be crammed on top of each other on y=12)

This issue is easy to fix:

1. Select all boxes and duplicate them.
2. Put them inside new empty parent GameObject.
3. Translate that GameObject by needed distance.
4. Take boxes out from that temporary parent and delete it.

Alternatively, you can fill required area with boxes with some help from free Immediate Window extension. It's very old but worked last time I checked (few months ago).

If you're going to level-design with this approach, better invest some time into creating editor script.