How do I make it possible to switch a Skin (Sprite) via Code?

Hello!
Since I am learning an IT Job (not Programming!) i am trying myself with programming some games for myself. I made a little “Dodge-the-obstacle” game in what you move you player left and right and dodge falling obstacles. Now i am trying to make some Skins you can choose in the Main Menu, like the Player with a hat or in different colors.

Now i actually do not know how to go on. I`ve created another Sprite in a different color, but what do i have to do now, to change the actual Players sprite? I have tried some things from forums but they were mostly made with animations etc. what i have not included so far.

Get access to Sprite Renderer and change the variable sprite to another sprite

public Sprite otherSprite;
SpriteRenderer sr;

void Start () {
sr = GetComponent <SpriteRenderer> ();
sr.sprite = otherSprite;
}
2 Likes

Thats just perfect, ty