Prefabs, hierarchy and organising assets

2D Game Design with Unity

🕑 This lesson will take about 9 minutes

In this lesson, you will learn how to organise your game’s objects and assets within individual scenes and the entire project. There are a few different techniques you can use to keep the project organised, reduce development time, make objects more reusable and improve your workflow.

  • Prefabs are templates that you can use to make GameObjects in your Unity project reusable. The Prefab system in Unity allows you to create a reusable GameObject that can be configured with all its different components (eg. Rigidbody, Collider2D, scripts), property values, and child GameObjects. You can then create new instances of the Prefab in a scene without having to configure all of the GameObject’s components again. This can save you a lot of time!

  • The Hierarchy panel lists all of the GameObjects that are in the current scene you are working on. The Hierarchy also has a hierarchy structure, allowing you to attach GameObjects to other GameObjects (so they become a ‘child’ GameObject), and grouping GameObjects together.

  • Organising assets involves using folders in your Assets directory to store different types of assets such as scripts, animations, sprites, etc. as well as using tags and layers. We will look at some of these techniques in the video below. Techniques for organising GameObjects and assets include:

    • Sorting layers - organise sprites on layers (eg. background, midground, foreground) so they appear behind or in front of other sprites

    • Prefabs - make your GameObjects easily reusable across the project

    • Folders - organise assets for your project into folders

    • Hierarchy - use the hierarchy to link objects together or group objects

    • Tags - use tags to distinguish between different objects (eg. during collisions detection)

Game art and sprites from the Free Pixel Space Platform pack are used in this lesson video and can be downloaded from the Unity Asset Store.

Is YouTube blocked at school? Watch on Google Drive.

Next lesson: Tilemaps