Author Topic: Disable dragging by code  (Read 4318 times)

Lord_Meshadieme

  • Guest
Disable dragging by code
« on: March 21, 2013, 01:04:13 PM »
Hello people,

Using nGUI's DragObject Script to drag something, how would i stop this dragging by code, or if the touch event is not in the hover state any more. i know it has to do with the UICamera event but for the heck of me i can't figure out how dragging stops from the drag object script. I'm definitely stepping on my own foot here sigh.

Regards.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disable dragging by code
« Reply #1 on: March 22, 2013, 02:07:09 AM »
Search for "OnDrop" event within the UICamera. I'm guessing in your case you will want to just set UICamera.currentTouch.pressed to null though.

PabloAM

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Disable dragging by code
« Reply #2 on: March 27, 2013, 07:05:30 AM »
And what is the way to re drag it still being pressed and over the collision ??

I just need to activate UIDragObject on runtime when the touch is inside the collision but is up to 75% of the localScale.
when I got more than 75% call to drag.enabled = true, but the object doesn´t get draggable.

Any reply would be awesome.

FIXED:

  1.         drag = GetComponent<UIDragObject>();
  2.  
  3.         drag.enabled = true;
  4.                                                        
  5.         SendMessage("OnPress",false,SendMessageOptions.DontRequireReceiver);
  6.                                
  7.         SendMessage("OnPress",true,SendMessageOptions.DontRequireReceiver);
  8.  
  9.  

Thanks
« Last Edit: March 27, 2013, 08:36:31 AM by PabloAM »