0
\$\begingroup\$

I am making a prefab of a simple building by combining sprites. As you can see in the Hierarchy view, this simple building is composed of very many gameobjects which I created via dragging sprites into the scene/Hierarchy and then manually editing their coordinate positions. Building with many game objects

Is there a simpler way of doing this? I feel that the process of creating this building consumed too much time I could spend on other aspects of development. If this is the only way, then in what ways could I optimize my workflow?

\$\endgroup\$
  • \$\begingroup\$ Why didn't you just create a grid and use tilemaps?? \$\endgroup\$ – Sean Carey Jan 23 at 0:26
  • \$\begingroup\$ I have a grid with a tilemap, but I need to make a prefab \$\endgroup\$ – Caleb Jan 23 at 1:11
  • \$\begingroup\$ Even if you're not using tiles, you should still create a grid and put all of the gameObjects inside that grid. That way, they snap to position, rather than you having to manually adjust their transform values. \$\endgroup\$ – Sean Carey Jan 23 at 1:38
  • 1
    \$\begingroup\$ You're welcome, but I think you can still use tilemaps. Create a new tilemap inside your grid, call it 'Building', recreate the building using tiles, then create a prefab out of that tilemap. \$\endgroup\$ – Sean Carey Jan 23 at 2:54
  • \$\begingroup\$ Excellent. I was hoping there'd be a solution like that. I'll accept that as the answer, if it is posted below. \$\endgroup\$ – Caleb Jan 23 at 3:19
1
\$\begingroup\$

Inside of the grid that you already have, create a new tilemap and call it 'Building'. Then create the building using tiles, and when you're done, just make a prefab out of that tilemap.

\$\endgroup\$
1
\$\begingroup\$

You could have used texture tiling from a mesh renderer to duplicate pieces automatically. 3D components can be used for 2D objects to add more complex functionality.Drag and drop the sprite you want to duplicate as a material in the parent game object and change the shader to 'unlit texture.' You can play with the offset and tiling settings. Make sure the wrap mode in your import settings is set to 'repeat.'

You could have done this even faster by using gimp for the editing. Gimp has built in functions and plugins that handle this use case well. Filters > Map > Tile is one.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.