1
\$\begingroup\$

I have a menu where the player gets to choose which team and kit he will use to play. However I don't really know how to change the sprite each time the left or right arrows are pressed. I already have the sprites for each team, league and kit the only thing I am missing is the way to arrange it via script. Thanks.

Team selection menu, the arrows display the image of the league, team and kit the player can choose to play with.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

You can store all sprites in a array and have a index for selected team for example something like this:

List<Sprite> Slist;
int Index = 0;
if(user press next)
    flagObject.GetComponent<SpriteRenderer>().sprite = Slist[Index++];
if(user press previous)
    flagObject.GetComponent<SpriteRenderer>().sprite = Slist[Index--];  

Although you should check for Index to not going out of bound.

\$\endgroup\$
0
\$\begingroup\$

You can do that using Unity UI's Scroll rect. Trick is to use a mask so that only one element can be displayed at a time. Refer Scroll Rect

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .