Complete the code to set the sorting layer of a SpriteRenderer to "Foreground".
spriteRenderer.sortingLayerName = "[1]";
Setting sortingLayerName to "Foreground" places the sprite on that layer.
Complete the code to set the sorting order of a SpriteRenderer to 5.
spriteRenderer.[1] = 5;
sortingLayerName instead of sortingOrder.layer or orderInLayer.The sortingOrder property controls the order within the sorting layer.
Fix the error in the code to correctly set the sorting layer to "Background".
spriteRenderer.[1] = "Background";
sortingLayer.The property sortingLayer does not exist. Use sortingLayerName to set the layer by name.
Fill both blanks to create a dictionary mapping sorting layer names to their order values.
var layerOrders = new Dictionary<string, int> { {"[1]", [2] };The dictionary maps the sorting layer "Background" to order 0.
Fill all three blanks to set the sorting layer to "UI", sorting order to 10, and print the values.
spriteRenderer.[1] = "UI"; int order = spriteRenderer.[2] = [3]; Console.WriteLine($"Layer: {spriteRenderer.sortingLayerName}, Order: {order}");
Set sortingLayerName to "UI", sortingOrder to 10, then print them.