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 /
  • Help Room /
avatar image
0
Question by AnnaB417 · Feb 04, 2016 at 02:45 PM · guibuttontogglenewstyle

what replaces Toggle Using Button Style in New GUI?

I would like to create toggles that look like regular buttons, or would like regular buttons to act as Toggles using the new Unity3D GUI (post 4.6) I'm on version 5.1.3. I've been searching and cannot find any documentation or tutorials that show how to do this in the new GUI. All Unity3D documentation I've found only shows how to do this in the legacy UI. I've already gone through this as well, in hopes of finding the answer: http://www.raywenderlich.com/114828/introduction-unity-ui-part-1 and the 2nd and 3rd part as well, but it doesn't show what replaces the toggle Using button style...

Hopefully a simple solution. Thanks in advance!

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 AnnaB417 · Feb 04, 2016 at 06:08 PM 0
Share

I've figured out how to make a Button act like a Toggle with the below code in my UI$$anonymous$$anager C# Script, and assigning (in the INSPECTOR) the GameObject "Pressed" to the UI$$anonymous$$anager script. HOWEVER: The button still appears like a button. When I press it, it momentarily changes color, but does not stay the same color. I am thinking I need to fetch a different image from within the script? public class TabletUI : $$anonymous$$onoBehaviour { public GameObject Pressed;

     private bool toggle = false;
 
     public void PB_1()
     {
 
         if (!toggle)
         {
            Pressed.SetActive(true);
             toggle = true;            
             Debug.Log("Sirens ON");
 
 
         }
         else
         {
             Pressed.SetActive(false);
             toggle = false;
             Debug.Log("Sirens OFF");
 
         }
     }
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AnnaB417 · Mar 16, 2016 at 09:52 PM

Ultimately, the TOGGLE UI element seems to replace the Toggle usingButton function. I've now got my project set up and working as intended by using 2D sprites and "sprite swap" in the Toggle transitions. So I've got one set of images to look like buttons off (not lit up) and another set of images that look like buttons turned on (indicator lights on). The Unity GUI interface sets up the Toggle as a Bool, so when clicked it returns "is on" for true, and unclicked for false. No addition scripting needed!

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

53 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

Related Questions

Toggle Button: hope it toggle once but it toggle many times 1 Answer

Calling functions via buttons when cooldown finished 1 Answer

Access GameObject Array and Turn Render on via the key pressed - Keys are already named based on game object. 0 Answers

Toggling checkbox in toggle in GUILayout.Toggle 1 Answer

Unity Broken Buttons 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