2
\$\begingroup\$

Since I am using NGUI, to capture mouse events I use their methods such as

void OnPress (bool isDown) {

}

How can I check the mouse/touch position that corresponds to this particular OnPress event?

\$\endgroup\$
  • \$\begingroup\$ Could you explain in detail what you want to do, and what you've already tried? \$\endgroup\$ – d4Rk Jun 5 '15 at 16:16
  • \$\begingroup\$ @d4Rk: I'm trying to spawn a sprite at the position the player presses with his finger. I have not tried anything because NGUI lacks documentation on how to get the position given a OnPress() callback. I am able to do this using Unity's Input class, but I want to use NGUI because my whole game is built with NGUI. \$\endgroup\$ – Oxide Jun 5 '15 at 16:46
  • \$\begingroup\$ Did you get it working? \$\endgroup\$ – d4Rk Jul 6 '15 at 18:01
1
\$\begingroup\$

Check out UICamera.currentTouch.pos or UICamera.lastTouchPosition in the OnPress method.

These will be set, whenever a touch is active, and should provide the necessary information.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.