- Home /
Prime 31 Touch Kit detecting if touch hit gui element
I installed the Prime 31 Touch Kit and its good, and i want to use it to pan my camera and look around. My problem is, when i touch some of the movement buttons(that i put on a canvas), prime 31 detects this. Is there any way that the script can ignore when i touch an element such as a button? I don't know where else to ask questions about this kit I thought this would be the best place.
It is this addon https://github.com/prime31/Touch$$anonymous$$it "the script" might have been the wrong wording but I tried searching the internet for help on how to use this but I didn't see too much support so i thought mabye someone here knew how to use it.
Answer by bojangles · Oct 27, 2015 at 07:46 PM
Use: EventSystem.current.IsPointerOverGameObject()
E.g.:
// This is on the camera object, and moves the projection camera up / down based on the pinch
// ONLY if it is not over an object within the EventSystem
private void PinchRecognizer_gestureRecognizedEvent(TKPinchRecognizer obj) {
if (!EventSystem.current.IsPointerOverGameObject()) {
float y = Mathf.Clamp(transform.position.y + (transform.position.y * obj.deltaScale), 5, 15);
transform.position = new Vector3(transform.position.x, y, transform.position.z);
}
}
Hey,
Somehow this method will only depend on where you cursor is at the moment you query this method.
Let's assume you started pressing a button, and while holding your cursor you moved out of the button bounding box, this method will return false. How can you handle this case? I still want to prevent gestures because the user might actually get his cursor back on the button to validate the press.
Best regards
Your answer
![](https://koobas.hobune.stream/wayback/20220611233051im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Unity3d Get Cube Pressed On Mobile 1 Answer
Detect swipe up gesture IOS 1 Answer
Android 2D multitouch joystick + buttons 0 Answers
Turning touch to rotation 1 Answer