Complete the code to get the Sprite Renderer component from the GameObject.
SpriteRenderer spriteRenderer = gameObject.GetComponent<[1]>();The GetComponent<SpriteRenderer>() method fetches the Sprite Renderer component attached to the GameObject.
Complete the code to change the sprite color to red.
spriteRenderer.color = [1];Setting spriteRenderer.color to Color.red changes the sprite's color to red.
Fix the error in the code to enable the Sprite Renderer component.
spriteRenderer.[1] = true;The enabled property controls whether the Sprite Renderer component is active and rendering.
Fill both blanks to set the sprite and flip it horizontally.
spriteRenderer.sprite = [1]; spriteRenderer.[2] = true;
Assigning newSprite to spriteRenderer.sprite changes the displayed sprite. Setting flipX to true flips the sprite horizontally.
Fill all three blanks to create a dictionary mapping sprite names to their colors if the color is not white.
var spriteColors = new Dictionary<string, Color>()
{
{ [1], [2] }
};
if (spriteColors[[3]] != Color.white)
{
Debug.Log("Color is not white.");
}The dictionary key is the sprite name as a string. The value is the sprite's color. The key is used again to check the color in the dictionary.