*Might have put this in the wrong section…
Hello everyone!
Touch input goes through UI and more
I’m bringing this up again, many people still have problems with this and do not have time to convert their game into the new raycasting thingy.
I am making this 3D tower defence game and when I build the game on my android device, touch input goes through panels, buttons, 3D objects and everything. For example it can go through a toggle, button below it and a panel, and activate something else below it in the game. With one touch.
Im using the latest version of unity.
I have searched and read everything related to this problem including youtube videos. I tried almost everthing and I still have the same problem. I have tried understanding raycasting and that would take forever to implement and understand in my complex game, wich was working perfectly in older versions of Unity.
It is almost 2018 and I know this problem is old, what is the easiest fix for ANDROID devices and most recent solution? The various solutions from 2014-2015 is not working. All I want is to deactivate ANDROID touch behind a object, simple as that.
Nothing in this thread works for me: Android touches pass through UI elements - Questions & Answers - Unity Discussions
I have tried using theese, on buttons, panels, gameobjects and such:
//EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)
//EventSystem.current.IsPointerOverGameObject(fingerId)
//EventSystem.current.IsPointerOverGameObject()
I did not find a working solution for my game.
Also I do not want something that runs in the update function (maybe this is where I will have to settle and change my mind…)… :
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class MouseExample : MonoBehaviour
{
void Update()
{
// Check if the left mouse button was clicked
if (Input.GetMouseButtonDown(0))
{
// Check if the mouse was clicked over a UI element
if (EventSystem.current.IsPointerOverGameObject())
{
Debug.Log("Clicked on the UI");
}
}
}
}
Again: * All I want is to deactivate ANDROID touch behind a UI object, simple as that.
Help
Best
Regards