Setting up a 2D Scene in Unity

Disclosure: This post may contain affiliate links, which means I may receive a small commission, at no cost to you, if you make a purchase through a link.

The scene setup, as the first thing you do in your new Unity project, can really help boost your productivity at the start of your game development cycle.

In the second half of 2020, and carrying on to 2021, I want to create a hypercasual mobile game with a fantasy backstory. I’m planning on trying out a total of 10 game ideas, before I settle on the best one and develop it to its best form.

I would like to document some of my game dev journey, and creates guides from what I learn. This is the first of those guides – and this one applies to almost any 2D game in Unity.

When you first download and open the Unity Hub, how do you create a project and set up the first scene for success?

Unity Hub and creating a project

Before you can start setting up the scene, you have to actually download and install Unity. The best way to do this is via Unity Hub – a tool used for Unity version, and project management. Download it from this link, and install it according to the shown instruction. Also install the latest version of Unity.

Create a new project in the window that pops up, and make sure to select 2D as the project template. Name the project, and click on Create. Let Unity do its magic. At this point (once everything loads), you have an empty scene; a blank canvas for you to work on.

The project creation window of Unity.

Folders, Hierarchy, Objects, and Components

Now I’d like to quickly show you how Unity is structured, so you can get a feel for the engine. Once you open your project for the first time, you should be seeing something like this.

A screenshot of an empty Unity project.

The bottom section is your Project window. Here, you can see the folders of the project. This is where you will have all your sprites, scripts, animations, fonts, audio, and all other assets. Make sure to organize everything into folders, so you can easily find your way through the project section as the project grows.

The left section features the Hierarchy. This is where all of your objects are going to be. Objects, such as your player, obstacles, camera, etc.

On the right, you can see the Inspector. When you select an object from the hierarchy, you will be able to see and edit all the information about the object here. Information about objects is stored in “Components”, which are basically like traits you’re adding to an object.

Finally, the middle section is the Scene/Game view. This is your actual game window – in here, you can see how the game looks, what objects you have in your scene (seen visually, as opposed to the text-based Hierarchy), etc. You can switch from the Scene view to the Game view by clicking on the tab in the upper section of this middle view.

In order to start your game, click on the Play button on the top of the window. At this point, you’ll just see an empty scene. So, let’s change that!

Setting up the scene (finally)

Now that you know what every section of the Unity window does, we can start working on the new scene.

When you now start the game (or switch to the Game tab), you’ll see the background is a solid, dark blue color. While that might suit your game, I want to change this color to something else. In my case, a dark grey will do.

In my Hierarchy, I’ll open the Scene dropdown, and select the Main Camera object.

A screenshot of Unity's hierarchy, along with the Main Camera object selected.

Once the Main Camera object is selected, you will see all of its Components and information about it pop up in the right-hand side of the Unity window – the previously mention Inspector.

Besides important data, like the Camera’s position, you can notice the “Background” value of the “Camera” component. I will change this value to the color I want to be in my game’s background.

A screenshot of Unity's Inspector window, with the Main Camera object selected.

A player object

Once the camera’s background is changed to a better color, I can create a small player object. In this case, I want the player to be a simple circle, but you can use any sprite you want to. In a different article, I can show you how you can create full on animations in Unity;

I will create a new folder in the bottom Project section of my screen. I’m calling the folder Images. In this folder, I am creating a new circle sprite – in the Create menu on right-click, I’m selecting Sprites, and Circle.

In the Hierarchy (section on the left), I’m right clicking and Creating Empty game object. I’ll name this object Player.

Now, I will be adding a new Component to this new object. In this case, the component is a Sprite Renderer, which basically gives an object a 2D image attached to it. Components can be added via the Inspector’s Add Component option.

In the Sprite Renderer Component itself, I’m setting the Sprite value to the Circle we created earlier. I will then change the circle’s color via the Color value. Finally, I’m making my player object a bit smaller through the Transform component (every object has this component by default).

A screenshot of Unity's Inspector, focusing on a Player object, which has a Sprite Renderer added on it.

This gives us a simple scene with a Player object. While this is not much, it’s a good start – in my next game development article, I will be writing a controller script for the player, which will allow us to actually move the orange circle around the map.

A screenshot of Unity's project view for a scene with a Player object.

Conclusion

With your very basic 2D scene set up, you will now be able to expand on the project as much as you want to. Keep an eye out for my next article about coding a player controller.

As there are not many gamedev tutorials in written form, I understand this might’ve been a bit weird for you. If you prefer guides in video form, check out this Unity course on Udemy.

I’ve created a checklist for setting up a 2D scene in Unity – you can access that by signing up to my email list below;

Subscribe to Eledris


 

I would also love to invite you to the Eledris Blog Discord server, where we host monthly game jams, you can chat with other game developers, and you can gain access to a ton of other exclusive resources!

Thank you for reading my article! If you have any feedback, I would love to hear from you in the comments below the article.

Leave a comment