chevron-up bell reply instagram twitter2 feed3 finder search-25px-p0

How to Align Game Objects in Unity


Tool: Unity 5.5 2017.3.0f3.

While using Unity, it is inevitable to have quite a amount of GameObjects in the scene. i.e. When designing an Arkanoid game, there are quite a lot blocks placed on the scene:

Figure 1. Messy Block Layouts

However, it might be boring and tedious to manually align all the red blocks in one line with the same gap.

Here is the trick you can do this in a much much faster/efficient way with only 2 steps:
1, Create an empty game object in the scene and drag and drop all the block_red game objects under the empty game object just created. In this case, it was named Block_RED. At the same time, select all the block_red game objects in the scene, and add Layout Element component in the inspector, and it will looks like:

Figure 2. Add a new Empty Game Object

2, Select the Block_RED game object, in the inspector window, add a component call Horizontal Layout Group. As in our case, we want to align all the objects horizontally. Set the spacing as 5.0, set the child alignment as middle center.

Figure 3. Final Review




Make Your Comments