Author Topic: Does NGUI provide mouse/touch detect function for custom use?  (Read 8950 times)

RiRin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Does NGUI provide mouse/touch detect function for custom use?
« on: November 10, 2012, 01:40:29 AM »
I want to create my custom draggable UI without UIDraggablePanel.
Is there any function in NGUI which I can use to detect mouse/touch event?
For example;
if(NGUI.GetTouchEvent("drag"))
{
  // do something.
}

Thank you in advance for your information.

dlewis

  • Guest
Re: Does NGUI provide mouse/touch detect function for custom use?
« Reply #1 on: November 10, 2012, 02:00:44 AM »
You will want to have a look at UICamera for the functions you need to watch for things such as touches and drags. onDrag, onPressed and onSelected are 3 that I can think of off the top of my head. Implement these functions in your code and you can do what you want with them.

DuckOfDoom

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 10
    • View Profile
Re: Does NGUI provide mouse/touch detect function for custom use?
« Reply #2 on: November 12, 2012, 11:34:18 AM »
There is a whole list of functions that get called on everything that is parented to UICamera on top of UICamera.cs script.
 
  1. /// - OnHover (isOver) is sent when the mouse hovers over a collider or moves away.
  2. /// - OnPress (isDown) is sent when a mouse button gets pressed on the collider.
  3. /// - OnSelect (selected) is sent when a mouse button is released on the same object as it was pressed on.
  4. /// - OnClick (int button) is sent with the same conditions as OnSelect, with the added check to see if the mouse has not moved much.
  5. /// - OnDoubleClick (int button) is sent when the click happens twice within a fourth of a second.
  6. /// - OnDrag (delta) is sent when a mouse or touch gets pressed on a collider and starts dragging it.
  7. /// - OnDrop (gameObject) is sent when the mouse or touch get released on a different collider than the one that was being dragged.
  8. /// - OnInput (text) is sent when typing (after selecting a collider by clicking on it).
  9. /// - OnTooltip (show) is sent when the mouse hovers over a collider for some time without moving.
  10. /// - OnScroll (float delta) is sent out when the mouse scroll wheel is moved.
  11. /// - OnKey (KeyCode key) is sent when keyboard or controller input is used.

You can implement the said functions for objects to receive events.