Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Neverdyne

Pages: [1]
1
NGUI 3 Support / OnClick events also trigger OnHover?
« on: June 22, 2014, 11:42:21 AM »
Hello,

I've noticed that when clicking an object, this sends both the OnHover and OnClick events to it. Why is this so? Is there a way to get OnHover events only when the mouse enters or leaves the collider, and not when while inside the collider a click happens?

Thanks!

2
NGUI 3 Support / Re: How to stop a drag?
« on: January 17, 2014, 04:11:58 PM »
Thank you for replying again! I've managed to make it work based on what you said. For future reference to anyone interested in this, what I did was alter the DragDropItem script slightly, giving it a new public member:

  1. public bool stopDrag = false;

And then changing the OnDrag method:

  1. void OnDrag(Vector2 delta)
  2. {
  3.     if (!enabled || mTouchID != UICamera.currentTouchID) return;
  4.     mTrans.localPosition += (Vector3)delta * mRoot.pixelSizeAdjustment;
  5.  
  6.     if (stopDrag)
  7.     {
  8.         UICamera.currentTouch.dragged = null;
  9.         UICamera.currentTouch.pressed = null;
  10.         stopDrag = false;
  11.         OnDragEnd();
  12.     }
  13. }

Then the only thing you need to do from an external source to stop the drag is set the "stopDrag" bool as true. So far it works.

3
NGUI 3 Support / Re: How to stop a drag?
« on: January 17, 2014, 11:34:55 AM »
Thank you for the reply, I'm trying to set:

UICamera.currentTouch.dragged = null;
UICamera.currentTouch.pressed = null;

However, I get an "Object reference not set to an instance of an object." error in Unity. Could this be because the "currentTouch" member is static?


4
NGUI 3 Support / Re: Alternative to trigger colliders while dragging.
« on: January 16, 2014, 10:46:34 PM »
Thanks for the reply! What I ended up doing was making my draggable item have a child transform with a collider of its own, seems to work so far.

5
NGUI 3 Support / How to stop a drag?
« on: January 16, 2014, 08:15:06 PM »
Let's say the player is dragging a DragDropItem object, how can you stop the drag and make the object return to its previous parent? Basically as if the player had released the item on a non-DragDropContainer surface.

UPDATE: So I managed to make the object return to it's parent, but the Camera keeps sending drag messages. So basically what I need is to make the Camera stop sending drag messages even if the player stays with the mouse button pressed down.

6
NGUI 3 Support / Alternative to trigger colliders while dragging.
« on: January 16, 2014, 05:23:27 PM »
Hello there, I'm making a scene where the player can drag a few sprites around, however I need to know if the sprites hit a trigger collider while being dragged. This only works when the player releases the dragged item and the item returns to it's original parent, passing through the collider on its way back, but it doesn't work when the player is dragging the item. I believe this is because when you drag an item the box collider in it is disabled, so the trigger collider can't detect a collision. Does anyone know a good and efficient way to detect collisions between static triggers and the dragged item, or at least provide the same functionality in a different way?

Pages: [1]