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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How would you implement a selection menu?

Discussion in 'Scripting' started by voyager3, Jun 18, 2017.

  1. voyager3

    voyager3

    Joined:
    May 15, 2017
    Posts:
    8
    Hello all, I'm trying to implement a selection menu.
    Let's say in HTML, what I want is something like this:
    <forum>
    <input type="checkbox">
    <input type="checkbox">
    <input type="checkbox">
    </forum>
    In my imagination, I have 3 option buttons in a canvas, when check one option, I just turn font's color to another color.
    Then I attached a script to my base canvas (let's say script A), and when user click on buttons, the button will call a function in script A, and the function will try to determine if user action is valid or not, then find appropriate sub button and change the color.
    I think this implementation looks stupid.
    Anyone who has better idea?
     
    Last edited: Jun 18, 2017
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    What's stupid about it?
    What is it you're trying to do ? just change the font colour when you press a button, or change the font / colour when the "right" button is selected?
     
  3. voyager3

    voyager3

    Joined:
    May 15, 2017
    Posts:
    8
    For example, I have 3 buttons, and I use them as checkbox. And the max number of checked is 2. So I need to create a script to verify if maximum 2 buttons/checkbox is checked. So I attach my script to my base canvas, and when user checks, call the function, verify, and find the text, and change the color.

    My puzzle is, it looks stupid when I have to find many times to get the right text and change the color.

    So I want to find a better way to do so.
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You aren't simply looking or the toggle and toggle group components?

    Otherwise I'm not sure I understand the question.
     
  5. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I agree that toggles & the toggle group could be used here.

    Of course you could use buttons and keep track of the count, too..I dunno.