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
1
Question by Concore Dev · Aug 23, 2013 at 06:02 PM · buttonkey pressedhow manybutton backround

Android Button

How do you make a button for android. Like you press on it and it reacts how you do that?

Comment
Add comment · Show 7
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 Sajidfarooq · Aug 23, 2013 at 06:05 PM 2
Share

What is your button made of? GUITexture or a 3D object?

Use Input.Touches to find out where the user tapped/touched the device, and then check if it is within the bounds of your button.

avatar image Concore Dev · Aug 23, 2013 at 06:33 PM 0
Share

Gui Texture

avatar image Concore Dev · Aug 23, 2013 at 07:03 PM 0
Share

Like A menu

avatar image Concore Dev · Aug 23, 2013 at 07:29 PM 0
Share

ejpaari is right.

avatar image Sajidfarooq · Aug 23, 2013 at 07:32 PM 1
Share

If you like an answer, then please mark it as "answered", ins$$anonymous$$d of simply saying he is right in the comments.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Sajidfarooq · Aug 23, 2013 at 07:07 PM

As I said earlier, the solution involves obtaining the touch position via input.touches . Then, simply check if the touch occurred within the bounds of the GUITexture:

 void Update()
 {
 foreach (Touch touch in Input.touches) 
     {
     if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
                 {
         if (guiTexture.HitTest(new Vector3(touch.position.x, touch.position.y, 0 ))
             {
             //Do something here on button click
             }
         }
             
         }
 }
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
0

Answer by ejpaari · Aug 23, 2013 at 07:07 PM

GUI Button works for Android aswel: http://docs.unity3d.com/Documentation/ScriptReference/GUI.Button.html

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 Concore Dev · Aug 23, 2013 at 07:16 PM 0
Share

Ok...... I dont understand

avatar image Sajidfarooq · Aug 23, 2013 at 07:19 PM 0
Share

@ejpaari: He is using a GUITexture, so that approach wont work.

avatar image Concore Dev · Aug 23, 2013 at 08:02 PM 0
Share

where am i supposed to put the script at

avatar image Sajidfarooq · Aug 23, 2013 at 08:04 PM 0
Share

@Concore-Dev: I strongly suggest you learn some basic program$$anonymous$$g before attempting this. Alternatively, you should post this in the Unity forums where you can generate a discussion.

avatar image
0

Answer by Concore Dev · Aug 23, 2013 at 08:31 PM

Im not a begginer this is my frirst time on android

Comment
Add comment · Show 1 · 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 Sajidfarooq · Aug 23, 2013 at 08:32 PM 0
Share

Please read the UnityAnswers FAQ. This question was supposed to be a comment ins$$anonymous$$d. Also, please mark a question as "answered" if it answers your question so that others, who have the same question, can benefit.

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

19 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

Related Questions

How to change the Source Image of a UI Button when the mouse is on it? 1 Answer

Is there any function to check how long a button is pressed? 2 Answers

Mirroring texture inside GUI.Button 0 Answers

On button press/hold = input from a keyboard? 1 Answer

UI button are sliced after exporting 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