Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new material with a shader.
Unity
Material mat = new Material(Shader.[1]("Standard"));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Shader.Create instead of Shader.Find causes errors because Create does not exist.
Using Shader.Load is incorrect because shaders are not loaded that way.
✗ Incorrect
The Shader.Find method locates a shader by name to assign it to a material.
2fill in blank
mediumComplete the code to assign a texture to the material's main texture slot.
Unity
mat.[1] = myTexture; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetTexture is a method that requires a property name, not a direct assignment.
Using GetTexture is for retrieving, not setting.
✗ Incorrect
The mainTexture property sets the main texture of a material.
3fill in blank
hardFix the error in the code to change the color of the material.
Unity
mat.color = new Color([1], 0.5f, 0.5f);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 255 causes the color to be invalid.
Using a string or boolean is not valid for color components.
✗ Incorrect
Color values must be floats between 0 and 1, so 1.0f is correct.
4fill in blank
hardFill both blanks to create a material and assign a texture property by name.
Unity
Material mat = new Material(Shader.[1]("Standard")); mat.[2]("_MainTex", myTexture);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Shader.Create instead of Shader.Find.
Using GetTexture instead of SetTexture to assign.
✗ Incorrect
Use Shader.Find to get the shader and SetTexture to assign a texture by property name.
5fill in blank
hardFill all three blanks to create a material, set its color, and assign a texture.
Unity
Material mat = new Material(Shader.[1]("Standard")); mat.[2] = new Color(1.0f, 0.0f, 0.0f); mat.[3] = myTexture;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Shader.Create instead of Shader.Find.
Trying to set color with a method instead of property.
Using SetTexture instead of mainTexture property for direct assignment.
✗ Incorrect
Use Shader.Find to get the shader, set the color property for red, and assign the mainTexture property.