Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by galshal · May 06, 2015 at 04:22 PM · uitoggle button

ui radio button

hi guys, Im trying to create a UI with a radio option button in it

in the unity UI I saw i can create a toggle, so i did.

  1. its not exsectly shaped as radio option button.

  2. I can choose 2 options, and thats somthing i cant have, how can I change it only to one

thanks in advance

Gal

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image flashframe · May 06, 2015 at 04:28 PM 2
Share

To allow only one selection at a time, use a toggle group. http://docs.unity3d.com/$$anonymous$$anual/script-ToggleGroup.html

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by tebandesade · May 06, 2015 at 08:05 PM

Hi ! To answer your first question, when you create a toogle you see that it has "background" as a child, click it. Now you'll see in the inspector that it has a Source Image below the Image (Script) componente. Press on the right side the circle to the right of the Source Image slot. Change your background image to whichever fits the shape you considered it is a radio option buttón.

Regarding your second question you have to add the toggle to a group. What does this mean. Create several toggles for instance and later select and drag (you have to do it simultaneously) one of the toggles different from the one you are seeing in the inspector from the Hierarchy View Panel and drag it to the Group property of the Toggle (Script) component . At the beginning you'll see the slot of this property saying None (Toggle Group). But once you drag and drop another Toggle it will appear the group that that toggle belongs to.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image galshal · May 07, 2015 at 09:02 AM 0
Share

thanks alot

avatar image ShawnFeatherly · Sep 23, 2015 at 09:23 PM 3
Share

I was unable to drag and drop another Toggle into the Group field of a selected Toggle. But dragging a gameobject that had a ToggleGroup on it worked.

avatar image electroid ShawnFeatherly · May 15, 2017 at 08:42 AM 0
Share

Thanks, $$anonymous$$Featherly, your answer is working fine for me.

avatar image mohansiriga · Jun 28, 2016 at 11:58 AM 0
Share

Hi tebandesade, Thanks, it is working fine. Clicking on one toggle is deactivating other toggles which are in same toggle group. I am trying to make use of this as "Tabs" functionality in my game. Clicking on one Tab, am showing its related tab data panel and deactivating other Tabs and its related data panels. But the problem is, when the user clicks on a tab that has already been clicked, it toggles off which makes my Tab related data deactivate. It is working fine unless clicking on already selected toggle. How can i make sure, clicking on already toggled on Tab to not to toggle off that Tab? any help would be much appreciated.... Thanks $$anonymous$$ohan

avatar image
2

Answer by yousuffahim8 · May 11, 2019 at 03:39 AM

I think this is exactly what you are looking for:

  int selected =0;
 public void OnGUI()
    {
 string[] options = new string[] { "  version 1", "  version 2" };
 selected = GUILayout.SelectionGrid(selected, options, 1, EditorStyles.radioButton);
 if (selected == 0)
                 {
                     Debug.Log("version 1 is selected");
                 }
 else if (selected == 1)
                 {
                     Debug.Log("version 2 is selected");
                 }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UI Toggle OnValueChanged sometimes forces me to select an input. 1 Answer

Toggles/Toggle Groups Question 0 Answers

Toggle Group event called 2 times Unity UI 1 Answer

Do Something ONLY when all Toggles are On or Off 4 Answers

Dropdown with multiple active options/choices(toggles)? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges