【发布时间】:2019-11-07 18:07:37
【问题描述】:
我有这段代码正在更新:
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Began)
{
touchPosition = touch.position;
if(arRaycastManager.Raycast(touchPosition, hits, UnityEngine.XR.ARSubsystems.TrackableType.PlaneWithinPolygon))
{
Pose hitPose = hits[0].pose;//ok
}
}
}
但现在我必须使用操纵杆让指针在屏幕上移动,然后按下按钮来做某事。
像这样:
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
fakeFinger.GetComponent<RectTransform>().anchoredPosition += new
Vector2(h * vel * Time.deltaTime, v * vel * Time.deltaTime);
//this move a pointer on my screen... I had to use RectTransform... dont know if its right
if (considerjoystickbuttonpressedok)
{
touchPosition = new Vector2(fakeFinger.GetComponent<RectTransform>().anchoredPosition.x,
fakeFinger.GetComponent<RectTransform>().anchoredPosition.y);
//still dont know if its right above...
if (arRaycastManager.Raycast(touchPosition, hits, UnityEngine.XR.ARSubsystems.TrackableType.PlaneWithinPolygon))
{
Pose hitPose = hits[0].pose;//NOT OK!
}
}
关于如何解决这个问题的任何想法?
【问题讨论】: