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
0
Question by AdamV · Nov 12, 2011 at 10:33 PM · buttonkeyboardautomatic

Make a GUI button automatically clicked down

Hi, I was wondering how I would be able to make a button automatically down without the player clicking and holding it. Thank you.

Comment
Add comment · Show 3
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 CHPedersen · Nov 13, 2011 at 12:30 AM 0
Share

Do you mean visually or functionally as well? That is, do you want a button that displays as constantly pressed after the user clicked it once, but executes only once, or are you asking about how to move the actual mouse pointer and invoke a button click in code?

avatar image AdamV · Nov 13, 2011 at 12:32 AM 0
Share

I just want it to display as constantly pressed without executing anything until the player presses a key.

avatar image CHPedersen · Nov 13, 2011 at 12:39 AM 0
Share

Okay. That's thankfully easy. :) See my answer below.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CHPedersen · Nov 13, 2011 at 12:39 AM

You can't make the default button exhibit that behavior, but you can fake it by playing around with the styles. :)

At its core, there is no magic about the appearance of a pressed button, it's just another texture. All buttons have textures for pressed and normal states. So, when you make your GUI.Button or GUILayout.Button, don't draw it with the default GUIStyle for a button - draw it with the GUIStyle for a textured label instead, and then replace the texture on the label manually each time the user clicks the button.

You can download the default Unity skin in this forum post:

http://forum.unity3d.com/threads/7173-Official-skins?p=84065#post84065

The button textures for pressed and normal states are in that package. Figure out which one is for pressed, and which one is for normal, and then just swap them on the label-style you draw the button with. That should give you the desired behavior.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

GUI.Button's status react to keyboard event? 0 Answers

When mobile keyboard is active, button clicks are not responding 0 Answers

how to use Gui.Buttons and keyboard ? 1 Answer

Click a button when keyboard is open (Android) 0 Answers

Is it possible to link a button on my keyboard to disable fog in-game? 1 Answer


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