IPointerClick not working on android device
Hello.I've been searching the web for a resolve to this for past two weeks and still haven't figure it out.
I have a script on ItemSlot
public class ItemSlots : MonoBehaviour,IPointerClickHandler,IPointerUpHandler,IPointerDownHandler
{
[SerializeField] Image image;
public event Action<Item> OnLeftClickEvent;
private Item _item;
public Item Item
{
get { return _item; }
set
{
_item = value;
if (_item == null)
{
image.enabled = false;
} else
{
image.sprite = _item.Icon;
image.enabled = true;
}
}
}
protected virtual void OnValidate()
{
if (image == null)
{
image = GetComponent<Image>();
}
}
public void OnPointerUp(PointerEventData eventData)
{
}
public void OnPointerDown(PointerEventData eventData)
{
}
public void OnPointerClick(PointerEventData eventData)
{
if (eventData != null && eventData.button == PointerEventData.InputButton.Left)
{
if (Item != null && OnLeftClickEvent != null)
OnLeftClickEvent(Item);
}
}
}
And EventSystem:
When I click the item it gets equipped on character via action OnLeftClickEvent in other script. Everything works in Editor, with mouse click, with touch display, even with simulate touches enabled. But when I build the app to my android device, I get no response from touching the slots. I have tried everything I have found on the internet, I got the new Input System too, attached Event Trigger,added Button component with :
public Button myButton;
void Start()
{
Button btn = myButton.GetComponent<Button>();
btn.onClick.AddListener(TaskOnClick);
}
public void TaskOnClick()
{
if (Item != null && OnLeftClickEvent != null)
OnLeftClickEvent(Item);
}
Still got same response. Works on editor but not on Device.
Do you guys have a suggestion or anything? It would be much appreciated.
Hi. Thank you for your interest. Yes I do, as you can see in the picture, the Inspector of EventSystem.
the only reason I can think of being unable to get click events is having something in front of your buttons blocking the clicks, that when changing the resolution of the game to the resolution of the phone gets infront. Have you tried checking the logs or using the autoconnect profiler?