目前正致力于移动3D无尽的亚军游戏 . 当按下UI按钮我的播放器运行动画 . 当触摸移动scree我的播放器攻击动画 . 但是我的问题是当按下UI按钮时都会运行和播放攻击动画 .

任何人都可以建议如何解决这个问题

using System.Collections;
using UnityEngine.EventSystems;
public class TestAgain : MonoBehaviour
{
float lastTouchForDouble, lastTouchForMulti, presentTouchTime = 0.3f,multiTouchTime = 0.2f;
    bool isTouch;
    public GameObject ant;
    public float zoomValue;
    float deltaMagnitudeDiff;
    Ray ray;
    RaycastHit  hit;
    public float scaleFactor;
    public float minScale = 0.05f;
    public  float maxScale = 1f;

    void Update ()//!EventSystem.current.IsPointerOverGameObject(pointerId)
    {   
        if (Input.touchCount > 0) {
            foreach (Touch touch in Input.touches) {
                if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)){
                    return;
                }
                int pointerId = touch.fingerId;

                    if (touch.phase == TouchPhase.Ended) {
                        if (Input.touchCount == 1 && Input.touchCount != 2) {
                            if (!isTouch) {
                                isTouch = true;
                            ray = Camera.main.ScreenPointToRay (touch.position);
                                if (Physics.Raycast (ray, out hit)) {
                                    if (hit.collider.name.Contains ("Player")) {
                                        // Player attack animation
                                    }
                                }
                            }

    public void OnButtonClick()
    {
        //Play run animation
    }