Author Topic: UIDragDropItem - Event when registered to new parent  (Read 5011 times)

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
UIDragDropItem - Event when registered to new parent
« on: July 23, 2014, 04:46:22 PM »
Good Day,

I am using the UIDragDropItem script ( 3.6.8 ) and I would like to receive a event when my object is moved to a new parent so I can perform some actions at this point.

The way I have done this is, in UIDragDropItem script in the method OnDragDropRelease (GameObject surface) I have added the following highlighted line

  1.             if (container != null)
  2.             {
  3.                 // Container found -- parent this object to the container
  4.                 mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;
  5.  
  6.                 Vector3 pos = mTrans.localPosition;
  7.                 pos.z = 0f;
  8.                 mTrans.localPosition = pos;
  9.  
  10.                 SendMessage("OnSubmit", this.gameObject); <--- New line
  11.             }

Would this be something that could be added or is there a way of doing this already that I am missing?

Cheers,




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragDropItem - Event when registered to new parent
« Reply #1 on: July 23, 2014, 09:14:01 PM »
You should derive from UIDragDropItem and overwrite its OnDragDropRelease function the same way ExampleDragDropItem does it.

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UIDragDropItem - Event when registered to new parent
« Reply #2 on: July 26, 2014, 06:01:23 PM »
yep... soz :)