【发布时间】:2019-12-03 09:36:52
【问题描述】:
我有一个应用程序可以在用户点击时生成模型,当用户点击模型时,会弹出一个菜单。
当用户点击除画布元素之外的任何其他位置时,菜单将关闭。
但这不起作用,当我按下画布元素时,它会检测到画布元素,但菜单仍然关闭。
这是我的代码:
void Update()
{
UpdatePlacementPose();
UpdatePlacementIndicator();
if (Input.touchCount > 0 )//&& Input.GetTouch(0).phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hit;
debugText.text = "touched";
// Check if finger is over a UI element
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
Debug.Log("Touched the UI");
debugText1.text = "Touched the UI";
isui = true;
}
else
{
isui = false;
if (Physics.Raycast(ray, out hit) && (hit.transform.name != "Quad"))
{
//debugText.text = hit.transform.name;
debugText.text = Input.touchCount.ToString();
if (IsSpawned)
{
debugText1.text = ColourImage.activeSelf.ToString();
ColourImage.SetActive(true);
//debugText.text = objectToPlace.name;
}
}
else
{
if (placementPoseIsValid && Input.touchCount > 0 && !IsSpawned)
{
PlaceObject();
IsSpawned = true;
PlayerPrefs.SetString("type", "medium");
}
else
{
ColourImage.SetActive(false);
}
}
}
}
//if (placementPoseIsValid && Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
//{
// PlaceObject();
//}
}
【问题讨论】:
标签: c# unity3d augmented-reality