How to display one image at a time

Hello! I am trying to created a 2D dress up game. I am going to have several different drop down menus where you can select different clothing items. However, I need to display one image at a time per menu.
For example, a shirt is selected, but the player wants to select a different shirt from the menu and it changes to the new one while removing the previously selected shirt. Is there a way to do this for a sprite?

Thank you!

If i understand correctly. And assuming you’re using unity UI.

//the main image
Public Image shirt;
//array of shirt sprites
Public Sprite[] shirts;
//set the main image to the first sprite in your array
shirt.GetComponent<Sprite>.sprite = shirts[0];

I’m on my phone and can’t test that but it should be kind of what you’re after. I may have the capitalization incorrect for sprite in the component might be .Sprite.
I’m no expert myself but until someone more experienced posts an answer you can try your luck with that.

Hi,
Try attaching this script to a game object with a sprite renderer component, drag several sprites from project to sprite list array in the script inspector, press play and hit space to change sprites.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChangeSprite : MonoBehaviour
{
    [SerializeField] private Sprite[] spriteList;
    private SpriteRenderer spriteRend;
    [SerializeField] private int indexR;
    private void Start()
    {
        spriteRend = this.GetComponent<SpriteRenderer>();
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (spriteList.Length >0)
            {
                indexR = Random.Range(0,spriteList.Length);
            }
            ChangeSpite(indexR);
        }
    }
    public void ChangeSpite(int index)
    {
        if (index < spriteList.Length)
        {
            spriteRend.sprite = spriteList[index];
        }

    }


}

If you use a button to triger sprite change then you want to make a new button on click event , drag game object with a script to an object field , select a changesprite method from a changesprite class and set integer paramter. here is the screenshot
link text