Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question navigate selection menu with only buttons?

Discussion in '2D' started by Tidcy, Jun 9, 2021.

  1. Tidcy

    Tidcy

    Joined:
    Apr 15, 2020
    Posts:
    53
    hello, im making a selection menu for a mobile game
    explanation.gif
    the way i wanna do this is by having non clickable buttons in the form of files on the screen (see the gif attached to know what i mean) and using the buttons (blue) i wanna be able to cycle through them (like in the gif) and then select the one highlighted using the pink button.

    Ive read about buttons in the unity docs but im still not sure how to achieve this .-.
    any help would be greatly appreciated
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,343
    There are probably a lot of ways, but you could have the "files" in an array and then when you click the blue buttons, it moves a highlight/selector effect to the next array index.

    Aka, you have code for highlighting the current index in the array. When you press the "next" blue button, it adds one to the index and the highlight is always over the current index.

    Hopefully that gives you an idea on how to get started.
     
  3. Tidcy

    Tidcy

    Joined:
    Apr 15, 2020
    Posts:
    53
    Thank you! That is helpful
    But may I ask how do I code a button to be highlighted?
     
  4. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,343
    Essentially, you have a highlight image/gameobject. Then you set its position to be over the proper object depending on the index in the array.

    So you will need either a set of If statements or use a Switch statemen to check what file is currently selected. Then, depending on the file's index in the array, you set the position where you need it. Check out highlighting or something similar on YT and you should find plenty of tutorials
     
    Tidcy likes this.