当对象被“点击”时,我需要获取凝视指针与Hololens中的对象之间的碰撞坐标。
所有示例都使用MRTK1,您如何在MRTK2中做到这一点?我知道您需要使用游标,但是如何获取它=它仅在我实际运行代码时出现。
这是我到目前为止所拥有的:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// define Foo...
modelBuilder.Entity<Foo>...etch...
// Then ignore Bar
modelBuilder.Ignore(Bar);
}
答案 0 :(得分:1)
弄清楚了。我不得不改用指针处理程序。这段代码有效:
public class MoveTo : BaseInputHandler, IMixedRealityPointerHandler
{
public GameObject Sphere;
public void OnPointerDown(MixedRealityPointerEventData eventData)
{
GetComponent<MeshRenderer>().material.color = Color.green;
}
public void OnPointerDragged(MixedRealityPointerEventData eventData)
{
}
public void OnPointerUp(MixedRealityPointerEventData eventData)
{
Vector3 gazePos = Sphere.transform.position;
Sphere.transform.position = eventData.Pointer.Result.Details.Point;
GetComponent<MeshRenderer>().material.color = Color.red;
}
public void OnPointerClicked(MixedRealityPointerEventData eventData)
{
}
}