0
0
Unityframework~30 mins

Material properties in Unity - Mini Project: Build & Apply

Choose your learning style9 modes available
Material properties
📖 Scenario: You are creating a simple Unity scene where you want to change the color and shininess of a material on a 3D object.
🎯 Goal: Learn how to access and modify material properties like color and shininess in Unity using C# scripts.
📋 What You'll Learn
Create a material variable in a script
Set the material color to red
Set the material shininess to 0.5
Print the material color and shininess values
💡 Why This Matters
🌍 Real World
Changing material properties is common in game development to create different looks and effects on 3D objects.
💼 Career
Understanding how to manipulate materials programmatically is important for Unity developers working on visual design and interactive environments.
Progress0 / 4 steps
1
Create a material variable
Create a public variable called myMaterial of type Material inside a class called MaterialChanger.
Unity
Need a hint?

Use public Material myMaterial; inside the class.

2
Set material color and shininess
Inside the Start() method of MaterialChanger, set myMaterial.color to Color.red and set myMaterial.SetFloat("_Glossiness", 0.5f) to change shininess.
Unity
Need a hint?

Use myMaterial.color = Color.red; and myMaterial.SetFloat("_Glossiness", 0.5f); inside Start().

3
Print material color and shininess
Still inside the Start() method, add two Debug.Log statements to print myMaterial.color and myMaterial.GetFloat("_Glossiness").
Unity
Need a hint?

Use Debug.Log to print the color and shininess values.

4
Run and check output
Run the Unity scene and observe the Console output showing the material color and shininess values.
Unity
Need a hint?

Open the Unity Console window to see the printed color and shininess values.