销毁 Arfoundation 中的游戏对象不起作用

Destroying a game object in Arfoundation not working

我正在尝试使用 ARFoundation 将对象生成到地平面,然后长按删除该对象。

但是销毁函数在这个里面不起作用respect.I已经使用了光线投射来识别物体。

if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
            RaycastHit hit;
            // Check if finger is over a UI element
            if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
            {
                Debug.Log("Touched the UI");
            }
            else if (Physics.Raycast(ray, out hit)&&(hit.transform.name.ToString()!= "Quad"))
            {
                if (Input.GetTouch(0).deltaTime > 0.2f)
                {
                    Destroy(hit.transform.gameObject);
                }
            }

            else
            {
                PlaceObject();
            }
        }

从第一个 if 语句中删除此代码;

Input.GetTouch(0).phase == TouchPhase.Began

因为如果它在那里,你的函数只会在触摸开始时调用一次。