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 /
  • Help Room /
avatar image
0
Question by TheHeftyCoder · Oct 29, 2016 at 11:49 AM · uiui imageinterfacedrag-and-dropcard

IDragHandler Interfaces handling multiple UIs

I have a UI image set as the parent and children as multiple UI images. I am setting my parent's dimensions in my Canvas Group and via a Layout Element. The thing is, I want to implement an IDragHandler interface for this whole object to use and I've succeeded in doing so. But somehow, the interface doesn't only recognize the parent as the object it needs to drag, but the child images as well. And of course, the child images (who have a sprite) have different dimensions than the parent itself. So, what happens is that the object is being dragged while not being visually clicked - touched.

Below is an example where my object - in this case- a card composed of many different images -( with sprites) will be dragged even when I begin dragging from the blue spot, which is inside my background's dimensions. (I know many will say that it may be a better practice for a card to be a simple UI Image sprite rather than creating a whole new 3D kind of object, but this was my kind of take on the subject and it seemed to be working well.)

alt text

The reason I want to use the IDragHandler Interface is because it communicates with the IDropHandler interface. I have managed to solve half of the problem by creating a drag script of my own that uses the OnMouse functions and a 2D BoxCollider, but I can't use the IDropHandler this way. Is there a possibility I can somehow limit what the IDrag perceives as "draggable", or should I go with the solution I found and implement my own version of a DropZone?

I have tried to also limit the UI by using Raycasting on my object, but while it works with only one image, it doesn't when there are many in the hand, because clicking on an object enables the IDragHandler for all of them.

I just figured that it is better to implement the UI Interfaces, rather than make your own. But I would like to know if there is a way to fix this before I find myself needing to code a solution from scratch.

Thanks a lot!

screenshot-7.png (296.7 kB)
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

1 Reply

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

Answer by TheHeftyCoder · Oct 30, 2016 at 12:49 AM

It seems the solution to this problem would be to disable the Raycast target for each child component and leave it on just for the parent itself. Quite easy I guess....

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

104 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 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 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 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 to change/fix Shader Graph node connection ports 3 Answers

Unity Canvas Grid Layout - Keep cells perfect squares and fit in parent 0 Answers

Moving UI Image 0 Answers

UI Clicking thought alpha of image 3 Answers

UI elements not showing up on World Space Canvas 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