Creating GameObjects and Applying Materials

Marc Frappier
3 min readMay 10

--

What are GameObjects in Unity?

When you are creating a game in Unity, everything you create is basically a GameObject.

They can represent characters, props, lighting. By themselves, they are simply containers for components which will then implement functionality.

Unity GameObjects

Creating a basic GameObject in Unity can be as simple as inserting a cube or a sphere into the scene.

Creating a simple 3D GameObject

Each GameObject has its own properties. For example, the cube we just created has a Transform which controls size and location in the scene, a Mesh Renderer which allows us to actually see the object including its materials, lighting, etc. These are located in the Inspector tab.

GameObject properties in Inspector Tab

When we insert a GameObject in a scene, its default color is white.

Basic GameObjects

Looking closely at the Inspector tab, we can see that there is a Materials section. It is here where we can change the color of our GameObject.

Materials in Mesh Renderer

In order to keep our files tidy, we will create a folder for the materials we are going to create. To do this, in the Assets section, right click, and from the pop-up menu select Create and then Folder. Name this folder Materials.

Creating a new folder

Creating and Applying Materials

Lets create a material for our cube. Right-click on the Materials folder, select Create and then Material.

Creating a New Material

Name the new material something appropriate like Cube_mat. Although it isn’t necessary to add the _mat, it will make your life a lot easier if you do, because when you want to search through your hundreds of materials in the future, it will be a lot easier to do a search for _mat.

When we select the material we just created, its properties will appear in the Inspector tab. Here, we will see the Albedo under Main Maps. This is where we can change the color of the material.

Material Properties

In order to choose a color for our material, select the white rectangle next to Albedo. A color wheel will pop up. Here we can select the color we want. Notice how the color of the material changes to the selected color.

Selecting a color

In order to apply this material to our GameObject, we can either drag directly on to the GameObject itself in the Scene window, or over the GameObject’s name in the Hierarchy pane.

Applying the material to a GameObject

To add a different material to the sphere, we would just follow the exact same steps as before, name the new material something like Sphere_mat, make it the color you want and then apply it to the sphere.

Applying Material to the sphere

That’s it for creating a basic 3D GameObject, creating a new material and applying it to the GameObject.

I hope you found this helpful. See you in the next post.

--

--

Marc Frappier

Poultry Scientist by profession, Computer Scientist at heart. After many years in the poultry business, I have decided to give my passion for technology a shot.