Changing multiple sprites at once in character customization menu

Hello!

I’m creating a character customization menu, and when it comes to the legs of the sprite, I want the player to select an outfit for “legs” that would change the sprites for both the left and the right leg. I’ll have different varieties of clothes such as jeans and leggings, and it wouldn’t make sense to give the player the option to select jeans for one leg and leggings for the other.

Using Unity’s Rikr sprite as an example:

When I select Poison for Right Leg, I want Left Leg to automatically change to Poison as well.

Does anyone know how I can write the script for this?

Thank you!

Generally “changing a sprite” involves finding the SpriteRenderer and setting its .sprite property.

Plenty of examples of that online, so get that working on a one-sprite basis first.

For better grasp of your multi-sprite changeout process, you might want to make a ScriptableObject that contains all the sprites related to a given outfit. Such a thing might look like:

using UnityEngine;
// @kurtdekker
// this lets you right-click in project to create instances of ThemedOutfit
[CreateAssetMenu]
public class ThemedOutfit : ScriptableObject
{
    public Sprite Shirt;
    public Sprite Pants;
    public Sprite LeftGlove;
    public Sprite RightGlove;
}

Tons of tutorials / examples of ScriptableObjects too, such as:

https://www.youtube.com/watch?v=raQ3iHhE_Kk