Adding a material
- Game Development course
- Beginner
- Lesson 16/83
- 4 min
Learn to create a new Material and assign it to your cube.
Material
A Material is the asset that decides how the surface of an object looks. You create a new material in the Project window with Create > Material. Changing its name in the Inspector makes it easy to find later.
Project > Create > Material
Ad: KupMalzemesiA material does not affect scene objects until it is assigned; giving it a color and assigning it to the cube comes next.
Color and assignment
The base color of a material is set by its Albedo option; you can pick any color from the color picker. To assign the material, drag it from the Project window and drop it onto the cube in the scene. After the assignment the material shows up in the Mesh Renderer section of the Inspector when the cube is selected.
Albedo: turuncu (#FF6A00)
Atama: materyali kupun uzerine surukle-birakThis way the cube appears in the color you chose instead of gray.
Practice Print the material info
Hold the material name as "KupMalzemesi" and the color as "turuncu" in two string variables. Print both on one line in the form Materyal: KupMalzemesi, Renk: turuncu.
Starter code
using System;
class Materyal {
static void Main() {
// Materyal adini "KupMalzemesi" olarak bir string ile tanimla
// Rengi "turuncu" olarak baska bir string ile tanimla
// Ikisini "Materyal: ... , Renk: ..." biciminde yazdir
}
}Sample solution
using System;
class Materyal {
static void Main() {
string materyalAdi = "KupMalzemesi";
string renk = "turuncu";
Console.WriteLine("Materyal: " + materyalAdi + ", Renk: " + renk);
}
}Expected output
Materyal: KupMalzemesi, Renk: turuncu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Where is a new material created?
- By right-clicking an empty area of the Hierarchy window
- In the Project window with Create > Material Correct answer
- Next to the Play button on the Toolbar
- By typing into the Position field of the Inspector
Explanation: Materials are project assets and are created in the Project window with Create > Material.
2 Write the Albedo color
string albedoRenk = "#____";
string albedoRenk = "#FF6A00";
Explanation: On the card the cube's Albedo color is given as orange, #FF6A00.
3 Material parts
| Term | Meaning |
|---|---|
Material |
Defines the surface look of an object |
Albedo |
The base color of the material |
Create > Material |
The way to create a new material |
Atama |
Linking the material to the cube |