3
\$\begingroup\$

I've recently switched to Unity 4.6. My previous workflow when creating continuous-input controls (the kind where you measure continuous touch input on a single button) was to create a GUITexture and then perform hit-testing on that texture as long as a finger was touching the screen.

With the new GUI there seems to be no way to measure this type of input, as GUITextures objects can no longer be created and the new UI types don't support hit testing.

I'm talking about a button that's supposed to act like a car accelerator where, for example, a simple OnClick() doesn't work because I need to measure if the button is being pressed continuously rather than it working as an on/off toggle. How can I implement this?

\$\endgroup\$
2
\$\begingroup\$

It turns out you can implement this using the event system.

The PointerDown and PointerUp events can be used to track when the start and stop of the continuous touch. I'm currently using them, and they work fine. It's preferred to use events rather than checking on every frame, I guess.

\$\endgroup\$
0
\$\begingroup\$

Use the EventTrigger component for more events that aren't build-into the button element.

\$\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.