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 Zeit · Jan 12, 2015 at 07:50 PM · unity 4.6

UI Button with special collider ( Unity 4.6 )

Hi!

I'm making a Risk kind-of game and I'm using Ui Images for the countries, but my problem is that UI Button uses the image boundaries so if my countries overlap the input fails a bit.

Is there any way of modifing the collider unity uses for the button input detection ?

I'm open to other suggestions!

Thanks!

Comment
Add comment · Show 4
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 Mmmpies · Jan 12, 2015 at 08:02 PM 0
Share

How do you want it to work?

Technically it's impossible to have two objects both clickable that overlap so you have to have a way to decide which one is being clicked.

Do you want the one the mouse is over to be selected until leaving that button entirely for example?

avatar image Zeit · Jan 12, 2015 at 08:11 PM 0
Share

I was thinking something more in the lines of what a Polygon collider is for a normal sprite.

I could use normal sprites but i would lose all the functionality of the UI Button wich is not hard to code but its really confortable

avatar image Mmmpies · Jan 12, 2015 at 08:20 PM 0
Share

Not familiar with Polygon collision but you can add an event for pointerEnter and pointerExit for the UI button.

You can also move the country button to the bottom of the UI in pointerEnter, which somewhat stupidly means that's the uppermost UI element.

The event system seems complex at first but definitely worth learning as it's pretty powerful and not that hard to learn.

With your polygon collider how would it tell which one to click if they overlap?

avatar image Zeit · Jan 12, 2015 at 08:22 PM 0
Share

Polygon collider is basically a mesh collider for 2D objects. It guarantees there will be no collisions. But using normal sprites might be less eficcient that using Unity's UI. But as I have no way of adding a custom collider for the buttons i think I'll have to do that

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mmmpies · Jan 12, 2015 at 08:39 PM

Try this then, add an event to the button. On the button click Add Component -> Event Trigger

Click on Add New Event Type

Select PointerEnter and click on the plus button. Drag your button onto the slot that appears.

then in the drop down select RectTransform -> SetAsLastSibling

Do that for each button and you should be sorted.

EDIT:

OK so that isn't working for you, I've been thinking about what you might be doing. When you say overlap, does the currently selected territory expand so it's larger than the others? Is that the issue?

Also, just thought of this, what if you create a transparent image of the territory that doesn't overlap and use that as the button rather than the image of the territory the player can see?

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 Zeit · Jan 12, 2015 at 08:47 PM 0
Share

I'll have the same problem, If I have A and B above eachother i might want to click B but A will be on top

avatar image Mmmpies · Jan 12, 2015 at 08:51 PM 0
Share

Can you post an image as I'm having trouble visualizing the issue?

Like I said you have to be able to pick which button we want to select, telepathy is out of the question at the moment (although an insider I know at Unity reckons they should have it cracked in Unity 7) ;¬)

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

26 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

Related Questions

How can I make an image maintain it's aspect ratio in Unity UI? 2 Answers

OnMouseUp open an external file 0 Answers

bug or a feature ?? 0 Answers

Unity4.6 gui working with sprites on different resolutions 1 Answer

Is there a bug in Unity 4.6.0? 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