0
0
Unityframework~10 mins

Sorting layers and order in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the sorting layer of a SpriteRenderer to "Foreground".

Unity
spriteRenderer.sortingLayerName = "[1]";
Drag options to blanks, or click blank then click option'
AForeground
BBackground
CDefault
DUI
Attempts:
3 left
💡 Hint
Common Mistakes
Using a sorting layer name that does not exist in the project.
Confusing sortingLayerName with sortingOrder.
2fill in blank
medium

Complete the code to set the sorting order of a SpriteRenderer to 5.

Unity
spriteRenderer.[1] = 5;
Drag options to blanks, or click blank then click option'
Alayer
BsortingLayerName
CsortingOrder
DorderInLayer
Attempts:
3 left
💡 Hint
Common Mistakes
Using sortingLayerName instead of sortingOrder.
Using non-existent properties like layer or orderInLayer.
3fill in blank
hard

Fix the error in the code to correctly set the sorting layer to "Background".

Unity
spriteRenderer.[1] = "Background";
Drag options to blanks, or click blank then click option'
AsortingLayer
BsortingLayerID
CsortingOrder
DsortingLayerName
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent property sortingLayer.
Confusing property names for sorting layers.
4fill in blank
hard

Fill both blanks to create a dictionary mapping sorting layer names to their order values.

Unity
var layerOrders = new Dictionary<string, int> { {"[1]", [2] };
Drag options to blanks, or click blank then click option'
AForeground
BBackground
C0
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the layer name and order values.
Using incorrect order numbers.
5fill in blank
hard

Fill all three blanks to set the sorting layer to "UI", sorting order to 10, and print the values.

Unity
spriteRenderer.[1] = "UI";
int order = spriteRenderer.[2] = [3];
Console.WriteLine($"Layer: {spriteRenderer.sortingLayerName}, Order: {order}");
Drag options to blanks, or click blank then click option'
AsortingLayerName
BsortingOrder
C10
Dlayer
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names.
Assigning the order value incorrectly.