Cloning colors quest - q1

Here is my code to change Colors inside ColorChanger.cs

public class ColorChanger : MonoBehaviour
{

    public enum ColorOptions
    {
        Red,
        Yellow,
        Blue
    }

    private SpriteRenderer mySpriteRenderer;
    [SerializeField] private ColorOptions myColor;

    void Awake()
    {
        mySpriteRenderer = GetComponent<SpriteRenderer>();
    }

    private void Start()
    {
        switch(myColor)
        {
            case ColorOptions.Red:
                mySpriteRenderer.color = Color.red; break;
            case ColorOptions.Yellow:
                mySpriteRenderer.color = Color.yellow; break;
            case ColorOptions.Blue:
                mySpriteRenderer.color = Color.blue;break;

        }
    }
}

Privacy & Terms