Author Topic: UIDragDropItem constrain behaviour?  (Read 5700 times)

Artrageous

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
UIDragDropItem constrain behaviour?
« on: October 05, 2014, 10:08:44 PM »
I have a question about objects using a UIDragDropItem script, and constraining them to a background object.

I am making a colour picker. I need to drag a cursor around on a coloured background.
This is easy to do, as per examples - cursor is a sprite with UIDragDropItem script, background is a sprite with UIDragDropContainer script.
However, I want to constrain the cursor so it cannot be dragged off the background sprite , but remains visible at the edge of background sprite when the drag leaves it.

What is the best way to do this?
I can put the background sprite on a UIPanel, and turn on clipping - this means you can't see the cursor when it is dragged off the background, but I want it to remain visible at the edge.
What does "Constrain but dont clip"? on the UIPanel script do?

I suppose could intercept the cursor's UIDragDropItem callbacks, and update the position so it remains on edge of the background?

Whats the recommended way to do this?

Thanks
Artrageous

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragDropItem constrain behaviour?
« Reply #1 on: October 06, 2014, 10:18:53 AM »
Don't use UIDragDropItem for this. Why would you? Just listen to OnDrag and move the cursor yourself. Constrain it as you need it.

Artrageous

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIDragDropItem constrain behaviour?
« Reply #2 on: October 06, 2014, 03:41:00 PM »
Thank you.

Artrageous