Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Multiple Active Toggles in a Toggle Group?

Discussion in 'Unity UI & TextMesh Pro' started by unity_uT2X6HlVKogv2g, Jan 20, 2018.

  1. unity_uT2X6HlVKogv2g

    unity_uT2X6HlVKogv2g

    Joined:
    Jan 11, 2018
    Posts:
    2
    A friend of mine and I are working on a little UI project in Unity.

    I'm handling most of the scripting and I've hit a road block working with toggles.

    What we have is a set of eight toggles and a user should only be able to select two of them at a time. The functionality should be similar to a toggle group, either deselecting the oldest selected toggle or just preventing the user from selecting additional toggles.

    Of course you can only have a single toggle selected in a toggle group at a time which is where the problem comes in. I'm having a hard time trying to figure out how I can code anything that will allow for a specific number of toggles to be selected.

    How the user is prevented from selecting more toggles isn't particularly important -- though if anyone could provide examples of both deactivating the remaining toggles and deselecting the oldest selected toggle (dequeue?) would be much appreciated -- so much as getting an example of how to impose the restriction.

    Any help anyone can provide would be much appreciated, thank you!
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,715
    Why not just ditch the toggle group & create your own code for what you want..
    You've pretty much described what you want.

    Keep track of the toggles in a list, and the count.
    If the count exceeds 2, toggle off the oldest one, move the (old newest) to the oldest, and the current to the newest.

    Try to write something up like that, and if you get stuck, post your script here and maybe someone can assist you further. :)
     
  3. unity_uT2X6HlVKogv2g

    unity_uT2X6HlVKogv2g

    Joined:
    Jan 11, 2018
    Posts:
    2
    That is actually exactly what I ended up doing. Heh, I guess I just needed to write out the problem to get a better grip on it.

    I put together some custom code and it's all working now. Took me a bit,but I think I'm good!
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,715
    Cool, glad ya got it working :)
     
  5. palalopea

    palalopea

    Joined:
    Dec 4, 2017
    Posts:
    3
    how to create multiple toggle in toggle group? because I created just once checked only.