Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by pgrenon · Dec 28, 2017 at 09:59 PM · toggledropdown

Dropdown with list of buttons instead of toggles

Hi, I'm trying to replicate the behaviour of a standard dropdown from the Unity UI but with a list of buttons instead of a list of toggles.

Here is what I want it to look like : http://gph.is/2zHDgdY

For the context: I'm trying to make an inventory system where each items are prefabs and have a different list of options. For example, the item "Wood" has Burn, Drop and Cancel, while the item "Berries" has Consume, Cook, Drop and Cancel.

Usually, the standard dropdown seems to use toggles because it assumes there would be a sort of "Submit" button, but I would like and effect to be triggered as soon as the user clicks a certain option. However, when I try to change the options elements to have a Button component instead of a Toggle component, I get the error "The dropdown template is not valid. The template must have a child GameObject with a Toggle component serving as the item.".

Thanks

Comment
Add comment
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

1 Reply

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

Answer by Larry-Dietz · Dec 28, 2017 at 10:25 PM

I don't think you can use buttons unless you roll your own dropdown component.

However, you can simulate it pretty easy.

In the Template, disable the Item Checkmark's Image componant, and replacing the Item Background image component's sprite with your button sprite. If your button already has the text for the button in the sprite, you can also disable the Text component in Item Label.

Your code will still have to check for which toggle is on, but the look and feel should be that of a button.

You can also disable the Text component of Label and and Image component of Arrow in the base of the DropDown, and change the DropDown image component to a button image to be clicked to access the DropDown, instead of displaying the text of the selected drop down item.

I know it isn't what you are looking for, but it is a quick easy way to get the appearance you want.

Hope this helps, -Larry

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 pgrenon · Dec 29, 2017 at 04:32 AM 0
Share

Hey thanks Larry,

That's what I tried actually and at the end of the day my best bet is probably gonna be, like you said, to mke my own dropdown.

$$anonymous$$y first thoigh would be to either instantiate a prefab of the options list or use a SetActive to make the options list appear.

Would you know what the simplest way is for making a dropdown menu kind of "appears gradually"? With Instantiate and SetActive, the game object would just instantaneously appear, but I don't know how to make it appear fluidly.

$$anonymous$$aybe an instantiate with a low alpha an lerp the alpha to the full?

Sorry if my terms aren't right i'm suuuuper newb!

avatar image Larry-Dietz pgrenon · Dec 29, 2017 at 05:31 AM 1
Share

I just pulled the source code for the DropDown.cs to see exactly what they were doing with the default DropDown.

Looks like they are just doing a tween on the alpha.

If you want to take a look at the source for the default dropdown to get some ideas on rolling your own, take a look at https://bitbucket.org/Unity-Technologies/ui/src/0bd08e22bc17bdf80bf7b997a4b43877ae4ee9ac/UnityEngine.UI/UI/Core/Dropdown.cs?at=5.2&fileviewer=file-view-default

It should give you a big leg up on writing one custom to use buttons.

Hope it helps, -Larry

avatar image pgrenon Larry-Dietz · Dec 29, 2017 at 05:18 PM 0
Share

Yo Larry you rock! Thanks a lot!

Show more comments

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

72 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 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 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

EditorGUILayout - dropdown / linked toggles & foldout+togglegroup combined 1 Answer

Gui dropdown select many items 0 Answers

Trouble disabling an option in a dropdown 0 Answers

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

UI Dropdown Bug 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