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

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

但是销毁功能在这方面不起作用。我使用了raycast来识别物体。

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();
            }
        }
aiaiai5 回答:销毁Arfoundation中的游戏对象不起作用

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

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

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

本文链接:https://www.f2er.com/3146034.html

大家都在问