IsPointerOverGameObject Not Working on Android
Hello, I am having a porblem with IsPointerOverGameObject on Android. On PC is works perfect but on Android my UI Buttons are just not working. This is my script and I am using the buttons from the standard assets. This is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityStandardAssets.CrossPlatformInput;
using UnityEngine.EventSystems;
public class Frog : MonoBehaviour {
public AudioClip MusicClip;
float directionX;
private AudioSource MusicSource;
private Scene scene;
private Rigidbody2D myBody;
void Awake()
{
myBody = GetComponent<Rigidbody2D>();
MusicSource = GetComponent<AudioSource>();
}
private void Update() {
directionX = CrossPlatformInputManager.GetAxis("Horizontal");
myBody.velocity = new Vector2(directionX * 8, 0);
if (!EventSystem.current.IsPointerOverGameObject(-1))
{
if (Input.GetMouseButtonDown(0))
myBody.MovePosition(myBody.position + Vector2.up);
}
} //update
void Start()
{
scene = SceneManager.GetActiveScene();
MusicSource.clip = MusicClip;
}
void OnTriggerEnter2D(Collider2D target)
{
if (target.tag == "Car")
{
Application.LoadLevel(scene.name);
}
if (target.tag == "Car")
{
MusicSource.Play();
}
}
} //class
Please tell me if you know what is the problem, thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612213855im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Loot table problems 1 Answer
Game crashes on iPhone 11 0 Answers
Need help with Mute Button 1 Answer
Frustrating UnityAds Please help 0 Answers
How do i have game object in the middle of a Catmull spline? 0 Answers