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 rd42 · May 05, 2010 at 03:46 PM · buttoniphonegetbutton

GetButton and buttonName - what is the buttonName

I want to try out GetButton. Just so happens that I have a button, but I don't know the name, is it "Hole in One!"? If not, how is a name give to a button. Thanks!

GUI.Button (Rect (3,430,105,50), "Hole in One!")
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

3 Replies

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

Answer by burnumd · May 05, 2010 at 07:21 PM

Input.GetButton (which is what I believe you're referring to) is used for physical inputs (mice, keyboards, joypads). The "virtual" button described in the docs is the named button assigned to a physical input in the Input Manager. You "read" GUI buttons as Cyclops pointed out in this answer. It is possible, however, to name a GUI button using GUI.SetNextControlName if that's what you're really after, although this approach is primarily used to manage GUI focus and not to make some action happen when a GUI button is pressed.

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 Cyclops · May 05, 2010 at 08:07 PM 0
Share

@burnumd good point, I hadn't thought about the GetButton() function, based on his code sample, but that certainly could be what he meant...

avatar image burnumd · May 05, 2010 at 08:25 PM 0
Share

Yeah, I think your answer gets at what the OP is actually trying to do (if I read the question correctly), just thought I'd provide an obscene number of links in case it's not. :)

avatar image Cyclops · May 05, 2010 at 08:31 PM 0
Share

Dang, but that's a lotta links... the Gui, half a dozen controls, my name, the other answer in the thread... sheesh. :)

avatar image rd42 · May 06, 2010 at 12:59 PM 0
Share

Yup, Input.GetButton was what I was getting at. It's cool that you can name a GUI button. Thanks for all the links :) I'll start taking a look.

avatar image
2

Answer by Cyclops · May 05, 2010 at 03:55 PM

The way you would use a Button is:

function OnGUI() {
    if (GUI.Button (Rect(3, 430, 105, 50), "Hole in One!")) {
        print("button pressed");
    }
}

It doesn't really have a name, rather you create it and check if it was pressed - then do some code if it was pressed.

Read over the GUI Scripting Guide for more help on how to use the GUI.

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
avatar image
1

Answer by instruct9r · Aug 03, 2012 at 06:32 PM

hi guys. I just found that threat, by searching in google for the buttons names.

I think R Delano, asked you how he can access a button, that was created by script.

For example if we have: GUI.Button(Rect(2, 5, 20, 50), "Example Button");

What will happen if, few lines below i want to make that Button, inactive, so the player can't click it. Can i access the Button's enable property? This way i can put it to 0 or 1...

I found that there is a GUI.enabled class variable, but how i can make it to be exactly for the button, i want it to be? Cuz i might have 10 buttons.... If the buttons have something like a system names, that we can use to reach their properties, etc...

Comment
Add comment · Show 2 · 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 AbdulRaman · Apr 27, 2018 at 03:59 PM 0
Share

hi did you find the solution ?

avatar image Bunny83 AbdulRaman · Apr 27, 2018 at 05:52 PM 0
Share

Please do not bump such old threads. The OP here (as well as most other people who posted here) seem to confuse GUI.Button with Input.GetButton. Those have absolutely nothing in common. GUI.Button creates a GUI button control inside OnGUI which will be displayed on the screen and can be clicked. Input.GetButton reads the state of a button that is defined in the Input$$anonymous$$anager. GetButton reads the state of a physical button (like a button on the keyboard).


Please, if you have a question, ask a question and do not bump old questions with comments like that.

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

iPhone Touch Screen? 2 Answers

GUI button fit on both iPhone and iPad 3 Answers

How to make Iphone Menu-Unity 2 Answers

Text is too small while displaying in device 1 Answer

iPhone Home button 2 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