- Home /
Touch goes through UI button
The problem is that when I tap my pause button, and then click resume, two balls will spawn. I added a line of code but it doesn't seem to be working:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems;
public class BallSpawn : MonoBehaviour {
public GameObject Ball;
public Touch _touch;
void Update () {
var pointerOverObject = UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject();
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began && !pointerOverObject){
Instantiate (Ball, transform.position, Quaternion.identity);
GameObject.Find ("Dropper first frame").GetComponent<Animator> ().Play ("DropperAnimation");
}
}
}
I removed your other post because it is a duplicate.
Hi, did you find an answer for this? I'm having the same problem, as alot of people are, this is most frustrating!
Answer by UniluckStudios · Jul 23, 2017 at 02:04 AM
I forgot to say this but I only want the balls to spawn when i click anywhere on the screen but the Button
Your answer
Follow this Question
Related Questions
Detect UI Button Click Event in Update method 3 Answers
UI button not working properly on samsung galaxy S6 1 Answer
I can't use more that two buttons at the time. How do I change that? 0 Answers
Holding down UI Button and shooting raycast from touch position doesn't work simultaneously:(( 0 Answers
Use touch to spawn a prefab 1 Answer