Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How to list images containing ID?

Discussion in 'Scripting' started by GreyOritsuka, Mar 31, 2024.

  1. GreyOritsuka

    GreyOritsuka

    Joined:
    Feb 21, 2023
    Posts:
    8
    So I'm confused, I want to try to make a picture matching game, but I don't really understand how it works. I think the way to match each image is to give each image an ID, that way I think I can match them. Back to the beginning, how? I'm still confused about where to start, do I need to create a list to save the image and the ID at the same time? or what?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,079
    As with any game you must create your own internal logic to track things like this ID, and to map them to a particular image.

    When a match of two particular images is made, look up the ID in your own structures and decide if it's a match.

    The ID could be an integer, a number, an enum, whatever you want to use. I recommend using a string so you can print it out with Debug.Log() as you're going and make sure your code is working as expected and doesn't have bugs.

    If that doesn't instantly give you the "ah ha!" moment, then work through at least two or three different tutorials out there for this extremely fundamental process. Not all of it will be text that can even be typed in this box.

    This is also known as "memory game."
    Screen Shot 2024-03-31 at 11.01.29 AM.png