Author Topic: UIDrag problem  (Read 2447 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
UIDrag problem
« on: July 01, 2012, 11:10:16 PM »
Simple question really, and struggling to figure out how to do it, but.

I want to drag a card onto a slot.

I have two objects, one I am moving around with UIDrag, All I want to do is drag it so it connects the other object and stay there. Now when I start dragging my object, I can't seem to figure out how to detect that it is hovering over the other one.

Looking in UIDragObject.target. All it finds is the current object that I am clicking on.
And combined with my other issue in another thread. When I am dragging my thumb on the screen, I don't seem to have a way to detect whether a button (or anything) is under my thumb.

I am feeling really stupid not being able to do something which I think should be quite straight forward.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrag problem
« Reply #1 on: July 01, 2012, 11:12:02 PM »
You need to disable the collider of the object you're dragging while it's being dragged.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UIDrag problem
« Reply #2 on: July 01, 2012, 11:26:00 PM »
That was going to be my next question. How do I check if an object is being dragged directly?
There doesn't seem to be anything in UIDragObject to check whether it is on the move.

ie

if (obj].GetComponentInChildren<UIDragObject>().isSelected == true)
{
}

If I check for

.enabled
.active

They are both always true.

[edit]

Ok, in the end I have simply decided to just use onDrag, detect for button presses and releases and then do the collision code separately.
« Last Edit: July 02, 2012, 12:50:41 AM by ENAY »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrag problem
« Reply #3 on: July 02, 2012, 01:02:34 AM »
OnPress(true) starts the drag. OnPress(false) ends it. OnDrag() is sent in-between.