Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unity3d 在uniy3d中检测UI触摸事件。。。。。。。。。。。。?_Unity3d_Touch_Unityscript_Unity5 - Fatal编程技术网

Unity3d 在uniy3d中检测UI触摸事件。。。。。。。。。。。。?

Unity3d 在uniy3d中检测UI触摸事件。。。。。。。。。。。。?,unity3d,touch,unityscript,unity5,Unity3d,Touch,Unityscript,Unity5,目前正在开发移动3D无止境跑步者游戏。当按UI按钮时,我的玩家正在运行动画。当触摸移动屏幕时,我的玩家正在攻击动画。但这里我的问题是当按下UI按钮时,运行和攻击动画都被播放 有人能建议如何解决这个问题吗 using System.Collections; using UnityEngine.EventSystems; public class TestAgain : MonoBehaviour { float lastTouchForDouble, lastTouchForMulti, pres

目前正在开发移动3D无止境跑步者游戏。当按UI按钮时,我的玩家正在运行动画。当触摸移动屏幕时,我的玩家正在攻击动画。但这里我的问题是当按下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
    }

需要更多信息。。UI按钮运行和触摸攻击的脚本看起来如何?(听起来你好像在触摸。任何地方计数>0,这意味着当你触摸按钮时它也会播放)我附加了我的代码,请在我的问题解决后检查