Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 TandT · Aug 11, 2015 at 09:16 AM · uiraycastbuttonpixel

How to click on irregular buttons in new ui

Hi

i have some very irregular button forms that are overlapping with there bounding boxes. So clicking on them is not working as expected (because of overlapping areas).

Perfect would be if i have a way to say "test alpha" for raycast or create better pixel perfect colliders. But i have no idea what the ideal/preferred way would be

Greetings Thomas

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by allenallenallen · Aug 11, 2015 at 09:17 AM

Polygon Collider 2D

http://docs.unity3d.com/Manual/class-PolygonCollider2D.html

And there's this:

http://forum.unity3d.com/threads/none-rectangle-shaped-button.263684/#post-1744521

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 NeverHopeless · Aug 11, 2015 at 09:27 AM

I also faced this situation when i have angular button. I Solved it by using PolygonCollider2D component, but the problem is, still there were overlapping areas in the angular buttons. To fix this I edited polygon collider component from inspector. There is also a possibility to detect which buttons were touched using Physics2D.OverlapAreaAll and find the most appropriate one based on criteria. But i personally feel its too hard to go with it if you can easily edit the collider component, since it is one time effort so it will not cost for performance each time as in the other case i discussed.

Hope it helps!

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 TandT · Aug 14, 2015 at 11:21 AM

Hi i now found the AlphaRaycaster it does exactly what i need and is already existing code. Well worth the money :-) https://www.assetstore.unity3d.com/en/#!/content/28601

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 dnwsaa58 · May 28, 2019 at 02:50 PM

If your button relies on an image to detect the click (with the RaycastTarget option checked), you can adjust the value of a threshold which specifies the minimum alpha a pixel must have for the event to considered a "hit" on the Image. See the documentation : Image.alphaHitTestMinimumThreshold

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Holding down UI Button and shooting raycast from touch position doesn't work simultaneously:(( 0 Answers

Raycasting UI components 3 Answers

UI button and raycast script that I have made both aren't working to change my scene 1 Answer

Unity 5 new UI Button Colliders moved to the left in different resolutions 1 Answer

Detect only UI button click 3 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